public class TypingLabel extends TextraLabel
Label that progressively shows the text as if it was being typed in real time, and allows the
use of tokens in the following format: {TOKEN=PARAMETER}.| Modifier and Type | Field and Description |
|---|---|
protected com.badlogic.gdx.utils.Array<Effect> |
activeEffects |
com.badlogic.gdx.utils.FloatArray |
offsets
Contains two floats per glyph; even items are x offsets, odd items are y offsets.
|
com.badlogic.gdx.utils.FloatArray |
rotations
Contains one float per glyph; each is a rotation in degrees to apply to that glyph (around its center).
|
com.badlogic.gdx.utils.FloatArray |
sizing
Contains two floats per glyph, as size multipliers; even items apply to x, odd items apply to y.
|
protected com.badlogic.gdx.utils.Array<com.github.tommyettinger.textra.TokenEntry> |
tokenEntries |
protected Layout |
workingLayout |
align, font, layout, storedText, style, wrap| Constructor and Description |
|---|
TypingLabel() |
TypingLabel(java.lang.String text,
Font font) |
TypingLabel(java.lang.String text,
Font font,
com.badlogic.gdx.graphics.Color color) |
TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style) |
TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style,
Font replacementFont) |
TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin) |
TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
Font replacementFont) |
TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
java.lang.String styleName) |
TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
java.lang.String styleName,
Font replacementFont) |
| Modifier and Type | Method and Description |
|---|---|
void |
act(float delta) |
void |
cancelSkipping()
Cancels calls to
skipToTheEnd(). |
void |
clearVariables()
Removes all variables from this label.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float parentAlpha)
If your font uses
Font.DistanceFieldType.SDF or Font.DistanceFieldType.MSDF,
then this has to do some extra work to use the appropriate shader. |
com.badlogic.gdx.graphics.Color |
getClearColor()
Returns a
Color instance with the color to be used on CLEARCOLOR tokens. |
java.lang.String |
getDefaultToken()
Returns the default token being used in this label.
|
long |
getFromIntermediate(int index) |
long |
getInLayout(Layout layout,
int index) |
java.lang.StringBuilder |
getIntermediateText() |
float |
getLineHeight(int index) |
Line |
getLineInLayout(Layout layout,
int index) |
java.lang.StringBuilder |
getOriginalText()
Similar to
Layout.toString(), but returns the original text with all the tokens unchanged. |
TypingListener |
getTypingListener()
Returns the
TypingListener associated with this label. |
com.badlogic.gdx.utils.ObjectMap<java.lang.String,java.lang.String> |
getVariables()
Returns an
ObjectMap with all the variable names and their respective replacement values. |
boolean |
hasEnded()
Returns whether or not this label's char progression has ended.
|
boolean |
isPaused()
Returns whether or not this label is paused.
|
boolean |
isSkipping()
Returns whether or not this label is currently skipping its typing progression all the way to the end.
|
void |
layout() |
void |
parseTokens()
Parses all tokens of this label.
|
void |
pause()
Pauses this label's character progression.
|
boolean |
remove() |
void |
restart()
Restarts this label with the original text and starts the char progression right away.
|
void |
restart(java.lang.String newText)
Restarts this label with the given text and starts the char progression right away.
|
protected void |
restoreOriginalText()
Restores the original text with all tokens unchanged to this label.
|
void |
resume()
Resumes this label's character progression.
|
protected void |
saveOriginalText(java.lang.CharSequence text)
Copies the content of
getOriginalText() to the StringBuilder containing the original
text with all tokens unchanged. |
void |
setDefaultToken(java.lang.String defaultToken)
Sets the default token being used in this label.
|
void |
setInLayout(Layout layout,
int index,
long newGlyph) |
void |
setIntermediateText(java.lang.CharSequence text,
boolean modifyOriginalText,
boolean restart) |
void |
setInWorkingLayout(int index,
long newGlyph) |
void |
setSize(float width,
float height) |
void |
setText(java.lang.String newText)
Modifies the text of this label.
|
protected void |
setText(java.lang.String newText,
boolean modifyOriginalText)
Sets the text of this label.
|
protected void |
setText(java.lang.String newText,
boolean modifyOriginalText,
boolean restart)
Sets the text of this label.
|
void |
setTypingListener(TypingListener listener)
Sets the
TypingListener associated with this label, or null to remove the current one. |
void |
setVariable(java.lang.String var,
java.lang.String value)
Registers a variable and its respective replacement value to this label.
|
void |
setVariables(java.util.Map<java.lang.String,java.lang.String> variableMap)
Registers a set of variables and their respective replacement values to this label.
|
void |
setVariables(com.badlogic.gdx.utils.ObjectMap<java.lang.String,java.lang.String> variableMap)
Registers a set of variables and their respective replacement values to this label.
|
void |
skipToTheEnd()
Skips the char progression to the end, showing the entire label.
|
void |
skipToTheEnd(boolean ignoreEvents)
Skips the char progression to the end, showing the entire label.
|
void |
skipToTheEnd(boolean ignoreEvents,
boolean ignoreEffects)
Skips the char progression to the end, showing the entire label.
|
java.lang.String |
toString() |
getAlignment, getPrefHeight, getPrefWidth, isWrap, setAlignment, setWrap, useIntegerPositionsgetMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validateaddAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFrontprotected final com.badlogic.gdx.utils.Array<com.github.tommyettinger.textra.TokenEntry> tokenEntries
protected final Layout workingLayout
public final com.badlogic.gdx.utils.FloatArray offsets
public final com.badlogic.gdx.utils.FloatArray sizing
public final com.badlogic.gdx.utils.FloatArray rotations
protected final com.badlogic.gdx.utils.Array<Effect> activeEffects
public TypingLabel()
public TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
public TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
Font replacementFont)
public TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
java.lang.String styleName)
public TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
java.lang.String styleName,
Font replacementFont)
public TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style)
public TypingLabel(java.lang.String text,
com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style,
Font replacementFont)
public TypingLabel(java.lang.String text,
Font font)
public TypingLabel(java.lang.String text,
Font font,
com.badlogic.gdx.graphics.Color color)
public void setText(java.lang.String newText)
restart(String) instead.setText in class TextraLabelnewText - a String that can contain Font markupprotected void setText(java.lang.String newText,
boolean modifyOriginalText)
modifyOriginalText - Flag determining if the original text should be modified as well. If false,
only the display text is changed while the original text is untouched. If true,
then this runs Parser.preprocess(CharSequence) on the text, which should only
generally be run once per original text.restart(String)protected void setText(java.lang.String newText,
boolean modifyOriginalText,
boolean restart)
modifyOriginalText - Flag determining if the original text should be modified as well. If false,
only the display text is changed while the original text is untouched.restart - Whether this label should restart. Defaults to true.restart(String)public java.lang.StringBuilder getOriginalText()
Layout.toString(), but returns the original text with all the tokens unchanged.protected void saveOriginalText(java.lang.CharSequence text)
getOriginalText() to the StringBuilder containing the original
text with all tokens unchanged.protected void restoreOriginalText()
parseTokens() to
parse the tokens again.public TypingListener getTypingListener()
TypingListener associated with this label. May be null.public void setTypingListener(TypingListener listener)
TypingListener associated with this label, or null to remove the current one.public com.badlogic.gdx.graphics.Color getClearColor()
Color instance with the color to be used on CLEARCOLOR tokens. Modify this instance to
change the token color. Default value is specified by TypingConfig.TypingConfig.DEFAULT_CLEAR_COLORpublic java.lang.String getDefaultToken()
public void setDefaultToken(java.lang.String defaultToken)
public void parseTokens()
public void skipToTheEnd()
public void skipToTheEnd(boolean ignoreEvents)
ignoreEvents - If true, skipped events won't be reported to the listener.public void skipToTheEnd(boolean ignoreEvents,
boolean ignoreEffects)
ignoreEvents - If true, skipped events won't be reported to the listener.ignoreEffects - If true, all text effects will be instantly cancelled.public void cancelSkipping()
skipToTheEnd(). Useful if you need to restore the label's normal behavior at some event
after skipping.public boolean isSkipping()
public boolean isPaused()
public void pause()
public void resume()
public boolean hasEnded()
public void restart()
public void restart(java.lang.String newText)
public com.badlogic.gdx.utils.ObjectMap<java.lang.String,java.lang.String> getVariables()
ObjectMap with all the variable names and their respective replacement values.public void setVariable(java.lang.String var,
java.lang.String value)
public void setVariables(com.badlogic.gdx.utils.ObjectMap<java.lang.String,java.lang.String> variableMap)
public void setVariables(java.util.Map<java.lang.String,java.lang.String> variableMap)
public void clearVariables()
public void act(float delta)
act in class com.badlogic.gdx.scenes.scene2d.Actorpublic boolean remove()
remove in class com.badlogic.gdx.scenes.scene2d.Actorpublic void setSize(float width,
float height)
setSize in class TextraLabelpublic void layout()
layout in interface com.badlogic.gdx.scenes.scene2d.utils.Layoutlayout in class TextraLabelpublic void draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float parentAlpha)
Font.DistanceFieldType.SDF or Font.DistanceFieldType.MSDF,
then this has to do some extra work to use the appropriate shader.
If Font.enableShader(Batch) was called before rendering a group of TypingLabels, then they will try to
share one Batch; otherwise this will change the shader to render SDF or MSDF, then change it back at the end of
each draw() call.draw in class TextraLabelbatch - parentAlpha - public java.lang.String toString()
toString in class com.badlogic.gdx.scenes.scene2d.Actorpublic void setIntermediateText(java.lang.CharSequence text,
boolean modifyOriginalText,
boolean restart)
public java.lang.StringBuilder getIntermediateText()
public long getInLayout(Layout layout, int index)
public float getLineHeight(int index)
public long getFromIntermediate(int index)
public void setInLayout(Layout layout, int index, long newGlyph)
public void setInWorkingLayout(int index,
long newGlyph)