DevJoy.Scene.Dialog (DevJoy v2.0.0)

View Source

A dialog is visually represented in a dialog box and contains text to be displayed. The character would be fetched at runtime making its data customisable using a data module.

Usage

The dialog always requires its content and character id. Optionally it's possible to add choices allowing to answer a question. You can also optionally specify additional data.

defmodule MyApp.SceneName do
  use DevJoy.Scene

  part :dialog do
    dialog :john_doe, "Dialog content"

    dialog :john_doe, "Dialog content", some: :data

    question :john_doe, "Question content" do
      choice "Answer content", goto(:part_name)
    end

    question :john_doe, [some: :data], "Question content" do
      choice "Answer content", goto(:part_name)
    end
  end
end

Summary

Field types

The type representing the content of the dialog.

The type representing the additional data for the dialog.

The type representing the dialog's type.

Main

The dialog structure contains the following keys

t()

The type representing the dialog structure.

Field types

content()

@type content() :: String.t()

The type representing the content of the dialog.

data()

@type data() :: Keyword.t()

The type representing the additional data for the dialog.

type()

@type type() :: :normal | :question

The type representing the dialog's type.

  • :normal - a general dialog (default)
  • :question - a question asked by the character

Main

%DevJoy.Scene.Dialog{}

(struct)

The dialog structure contains the following keys:

  • character - a character associated with the dialog or nil
  • content - a content of the dialog
  • data - a keyword list of additional data for the dialog
  • type - the type of the dialog

t()

@type t() :: %DevJoy.Scene.Dialog{
  character: DevJoy.Character.t() | nil,
  content: content(),
  data: data(),
  type: type()
}

The type representing the dialog structure.