DialogueView

Extends: BGE.UI.UiContainer

A dialogue box for a BGE.Story.StorySession: the speaker's name, the current line wrapped and split into pages, and the choices as buttons (disabled ones dimmed).

  • OK turns the page, then moves the conversation on. Up/down move between choices and OK picks one. Back leaves (closeOnBack).
  • It takes all input while it's open, opens a modal (Game.pushModal()) unless modal is false, and closes itself when the conversation ends.
  • Steps go through the session, so posts, messages and saving all happen there.

Colors come from the theme (panelBackgroundColor/Image, panelTitleColor for the speaker, panelTextColor), fonts from speakerFontName/textFontName. It sits along the bottom of the title-safe area unless you set customX/customY/width.

Choices: choiceLayout picks "column" (buttons above the box), "row" (buttons along its bottom) or "list" (lines of text in the box, under the line that asked - see the list* fields). Anything else is yours: override createChoiceButton()/createChoiceRow() for your own widgets and layoutChoices() to place them, or onLine()/onEnded() (or set listener) to react. It's only one way to show a StorySession - a game can drive the session from its own UI instead.

Properties

  • session (BGE.Story.StorySession)
  • linesPerPage (integer) — Wrapped lines shown at once.
  • boxPadding (float)
  • speakerGap (float) — Space between the speaker and the text.
  • speakerFontName (string)
  • textFontName (string)
  • moreText (string) — Shown in the bottom right while there's another page.
  • choiceLayout (string) — "column": buttons stacked above the box. "row": buttons side by side along the bottom of
  • listKeepsLine (boolean) — "list": keep the speaker and line showing above the choices?
  • listDivider (boolean) — "list": a rule between the line and the choices? Its color; 0 = the theme's panelTitleColor.
  • listDividerColor (integer)
  • listMarker (string) — "list": the focused choice's marker (the others are indented to match).
  • listTextColor (integer) — "list": choice colors; 0 = the theme's panelTextColor / panelTitleColor.
  • listFocusedColor (integer)
  • listDisabledColor (integer)
  • listRowHeight (float) — "list": height of each choice line; 0 = the text font's line height plus 6.
  • choiceHeight (float)
  • choiceGap (float)
  • choiceWidth (float) — Column choices' width; 0 = 60% of the box.
  • showDisabledChoices (boolean) — List choices the story marks disabled (dimmed, not pickable)?
  • closeOnBack (boolean)
  • advanceButton (string) — Buttons (GameInput.isButton() names) that turn the page / leave.
  • cancelButton (string)
  • advanceAction (string) — A Game.controls action (bindAction() name) that also turns the page and picks the
  • choicesWithLastLine (boolean) — Do a node's choices come up with its last page (true), or after one more press of
  • modal (boolean) — Pause the game while open?
  • backgroundImage (dynamic) — Drawn behind the box instead of the theme's panel background, when set (a
  • listener (dynamic) — Optional object told about the conversation: onDialogueLine(view, line) and
  • choiceButtons (Array.<BGE.UI.Button>) — The choice buttons on screen, in story order.
  • speakerLabel (BGE.UI.Label)
  • textLabel (BGE.UI.Label)
  • moreLabel (BGE.UI.Label)
  • pages (Array.<string>)
  • pageIndex (integer)

Example

CODE
view = new BGE.Story.DialogueView(game, session)
view.start("bram") ' opens if the node has something to say

Constructor

new DialogueView( game: BGE.Game, session: BGE.Story.StorySession, ): DialogueView

Parameters

  • game (BGE.Game)
  • session (BGE.Story.StorySession)

Instance Methods

start(nodeId: string, parent?: BGE.UI.UiContainer): boolean

Starts a conversation at a node and opens the box if there's something to show.

Parameters

  • nodeId (string)
  • parent (BGE.UI.UiContainer, optional, default: "invalid") — see open()

Returns

  • boolean — true if it opened

open(parent?: BGE.UI.UiContainer): void

Opens the box on the session's current conversation. With no parent it's owned by the current scene (scene.addUi()).

Parameters

  • parent (BGE.UI.UiContainer, optional, default: "invalid")

Returns

  • void

close(): void

Closes the box, cancelling the conversation if it's still going.

Returns

  • void

isOpen(): boolean

Is the box open?

Returns

  • boolean

hasMorePages(): boolean

Is there another page of the current line?

Returns

  • boolean

getPageText(): string

The page of text on screen.

Returns

  • string

next(): void

Turns the page, or moves the conversation on from the last page. Does nothing while choices are up.

Returns

  • void

choose(index: integer): void

Picks a choice by its index in runner.choices().

Parameters

  • index (integer)

Returns

  • void

onUiAction(actionId: string, button: BGE.UI.Button): void

Parameters

  • actionId (string)
  • button (BGE.UI.Button)

Returns

  • void

onInput(input: BGE.GameInput): void

Parameters

Returns

  • void

onDestroy(): void

Returns

  • void

draw(parent?: BGE.UI.UiWidget): void

Parameters

  • parent (BGE.UI.UiWidget, optional, default: "invalid")

Returns

  • void

onLine(line: BGE.Story.StoryLineView): void

Called for each line as it's shown (e.g. to set portraits). Tells the listener.

Parameters

  • line (BGE.Story.StoryLineView)

Returns

  • void

onEnded(cancelled: boolean): void

Called once the box has closed. Tells the listener.

Parameters

  • cancelled (boolean) — true if the player left before the end

Returns

  • void

createChoiceButton( choice: BGE.Story.ChoiceView, index: integer, ): BGE.UI.Button

protected

Parameters

  • choice (BGE.Story.ChoiceView)
  • index (integer)

Returns

  • BGE.UI.Button

createChoiceRow( choice: BGE.Story.ChoiceView, index: integer, ): BGE.UI.Button

protected

Parameters

  • choice (BGE.Story.ChoiceView)
  • index (integer)

Returns

  • BGE.UI.Button

layoutChoices(buttons: Array.<BGE.UI.Button>): void

protected

Parameters

  • buttons (Array.<BGE.UI.Button>)

Returns

  • void

showStep(): void

protected

Returns

  • void

showLine(): void

protected

Returns

  • void

showPage(index: integer): void

protected

Parameters

  • index (integer)

Returns

  • void

showChoices(): void

protected

Returns

  • void

removeChoices(): void

protected

Returns

  • void

layoutListChoices(buttons: Array.<BGE.UI.Button>): void

protected

Parameters

  • buttons (Array.<BGE.UI.Button>)

Returns

  • void

setHeightKeepingBottom(height: float): void

protected

Parameters

  • height (float)

Returns

  • void

fontNamed(name: string): roFont

protected

Parameters

  • name (string)

Returns

  • roFont

boxHeight(): float

protected

Returns

  • float

buildLabels(): void

protected

Returns

  • void

makeLabel( font: roFont, color: integer, x: float, y: float, ): BGE.UI.Label

protected

Parameters

  • font (roFont)
  • color (integer)
  • x (float)
  • y (float)

Returns

  • BGE.UI.Label

finish(cancelled: boolean): void

protected

Parameters

  • cancelled (boolean)

Returns

  • void