PixelCrushers.DialogueSystem.FormattedText Class Reference

A line of text including formatting. More...

Collaboration diagram for PixelCrushers.DialogueSystem.FormattedText:

Public Member Functions

 FormattedText (string text=null, Emphasis[] emphases=null, bool italic=false, int position=NoAssignedPosition, bool forceMenu=true, int pic=NoPicOverride, int picActor=NoPicOverride, int picConversant=NoPicOverride, string variableInputPrompt=null)
 Initializes a new FormattedText. More...
 

Static Public Member Functions

static FormattedText Parse (string rawText, EmphasisSetting[] emphasisSettings)
 Parses the text from a dialogue entry, which may contain formatting codes, and returns a FormattedText. More...
 
static string ParseCode (string rawText)
 Replaces var and lua markup tags in text. More...
 
static FontStyle GetFontStyle (Emphasis emphasis)
 Gets the Unity FonyStyle represented by an emphasis. More...
 

Static Public Attributes

static readonly FormattedText empty = new FormattedText()
 Represents an empty line. More...
 
static readonly Emphasis[] noEmphases = new Emphasis[0]
 Represents an empty set of emphases. More...
 
const int NoAssignedPosition = -1
 Constant: indicates that the response has no specifically-assigned position and can be placed anywhere in the player response menu. More...
 
const int NoPicOverride = 0
 Constant: indicates that there is no picture override for this pic tag. More...
 

Properties

string text [get, set]
 Gets or sets the "clean" line of text, without formatting codes. More...
 
Emphasis[] emphases [get, set]
 Gets or sets the list of emphases. More...
 
bool italic [get, set]
 Gets or sets a value indicating to display the entire line in italics. More...
 
int position [get, set]
 Gets or sets the response button position, for response text. More...
 
bool forceMenu [get, set]
 Gets or sets a value indicating whether this response forces display of the response menu, even if there's only one response. More...
 
int pic [get, set]
 Gets or sets the [pic=#] value. More...
 
int picActor [get, set]
 Gets or sets the [pica=#] value. More...
 
int picConversant [get, set]
 Gets or sets the [picc=#] value. More...
 
string variableInputPrompt [get, set]
 Gets or sets the variable input prompt. More...
 
bool hasVariableInputPrompt [get]
 Returns true if the formatted text includes a variable input prompt. More...
 

Detailed Description

A line of text including formatting.

Chat Mapper and the dialogue system support formatting codes inside lines of dialogue. This class represents a line where the formatting codes have been extracted and stored in separate formatting variables (emphases and italic).

Constructor & Destructor Documentation

◆ FormattedText()

PixelCrushers.DialogueSystem.FormattedText.FormattedText ( string  text = null,
Emphasis[]  emphases = null,
bool  italic = false,
int  position = NoAssignedPosition,
bool  forceMenu = true,
int  pic = NoPicOverride,
int  picActor = NoPicOverride,
int  picConversant = NoPicOverride,
string  variableInputPrompt = null 
)

Initializes a new FormattedText.

Parameters
textThe clean line of text, without formatting codes.
emphasesEmphases.
italicItalic.
positionPosition.
forceMenuForce menu.
picThe [pic] value, or 0 for unused.
picActorThe [pica] value, or 0 for unused.
picConversantThe [picc] value, or 0 for unused.

Member Function Documentation

◆ GetFontStyle()

static FontStyle PixelCrushers.DialogueSystem.FormattedText.GetFontStyle ( Emphasis  emphasis)
static

Gets the Unity FonyStyle represented by an emphasis.

Returns
The font style.
Parameters
emphasisEmphasis.

◆ Parse()

static FormattedText PixelCrushers.DialogueSystem.FormattedText.Parse ( string  rawText,
EmphasisSetting[]  emphasisSettings 
)
static

Parses the text from a dialogue entry, which may contain formatting codes, and returns a FormattedText.

The Parse() method handles these tags:

  • Pipe (|): Replaced with newlines.
  • [a]: Italics.
  • [f]: Force response menu.
  • [position #]: Response button position.
  • [em#].../em#. Currently records only one emphasis unless rich text is enabled.
  • [var=varName]: Replaces tag with the value of a variable. Example: "Hello, [varName=Actor].".
  • [lua(xxx)]: Replaces tag with the result of Lua code xxx. Example: "Hello, [lua(Variable['Actor'])].". Lua tags are processed first, so your Lua code can return other formatting codes that will then be parsed properly.
Parameters
rawTextThe raw text to parse.
emphasisSettingsThe emphasis settings to use (usually from DialogueManager.MasterDatabase) when parsing [em#] tags.

◆ ParseCode()

static string PixelCrushers.DialogueSystem.FormattedText.ParseCode ( string  rawText)
static

Replaces var and lua markup tags in text.

Parameters
rawTextThe raw text.
Returns
The text with var and lua markup tags evaluated and replaced.

Member Data Documentation

◆ empty

readonly FormattedText PixelCrushers.DialogueSystem.FormattedText.empty = new FormattedText()
static

Represents an empty line.

◆ NoAssignedPosition

const int PixelCrushers.DialogueSystem.FormattedText.NoAssignedPosition = -1
static

Constant: indicates that the response has no specifically-assigned position and can be placed anywhere in the player response menu.

◆ noEmphases

readonly Emphasis [] PixelCrushers.DialogueSystem.FormattedText.noEmphases = new Emphasis[0]
static

Represents an empty set of emphases.

◆ NoPicOverride

const int PixelCrushers.DialogueSystem.FormattedText.NoPicOverride = 0
static

Constant: indicates that there is no picture override for this pic tag.

Property Documentation

◆ emphases

Emphasis [] PixelCrushers.DialogueSystem.FormattedText.emphases
getset

Gets or sets the list of emphases.

An Emphasis specifies special formatting for a substring of the text.

The emphases.

◆ forceMenu

bool PixelCrushers.DialogueSystem.FormattedText.forceMenu
getset

Gets or sets a value indicating whether this response forces display of the response menu, even if there's only one response.

true to force the response menu; otherwise, false.

◆ hasVariableInputPrompt

bool PixelCrushers.DialogueSystem.FormattedText.hasVariableInputPrompt
get

Returns true if the formatted text includes a variable input prompt.

true if has variable input prompt; otherwise, false.

◆ italic

bool PixelCrushers.DialogueSystem.FormattedText.italic
getset

Gets or sets a value indicating to display the entire line in italics.

true if italic; otherwise, false.

◆ pic

int PixelCrushers.DialogueSystem.FormattedText.pic
getset

Gets or sets the [pic=#] value.

The pic index, where 0<c/c> means unused.

◆ picActor

int PixelCrushers.DialogueSystem.FormattedText.picActor
getset

Gets or sets the [pica=#] value.

The pica index, where 0<c/c> means unused.

◆ picConversant

int PixelCrushers.DialogueSystem.FormattedText.picConversant
getset

Gets or sets the [picc=#] value.

The picc index, where 0 means unused.

◆ position

int PixelCrushers.DialogueSystem.FormattedText.position
getset

Gets or sets the response button position, for response text.

The position, or NoAssignedPosition if there's no [position #] tag in the text.

◆ text

string PixelCrushers.DialogueSystem.FormattedText.text
getset

Gets or sets the "clean" line of text, without formatting codes.

The text.

◆ variableInputPrompt

string PixelCrushers.DialogueSystem.FormattedText.variableInputPrompt
getset

Gets or sets the variable input prompt.

If this is set, the value is the name of the variable to prompt for input.

The variable name.


The documentation for this class was generated from the following file: