Package arc.flabel
Class FLabel
java.lang.Object
arc.scene.Element
arc.scene.ui.Label
arc.flabel.FLabel
An extension of
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}.
Code taken and ported from https://github.com/rafaskb/typing-label-
Nested Class Summary
Nested classes/interfaces inherited from class arc.scene.ui.Label
Label.LabelStyle
-
Field Summary
Fields inherited from class arc.scene.ui.Label
cache, ellipsis, fontScaleChanged, fontScaleX, fontScaleY, labelAlign, lastPrefHeight, layout, lineAlign, prefSize, prefSizeInvalid, prefSizeLayout, style, tempColor, text, wrap
Fields inherited from class arc.scene.Element
color, cullable, fillParent, height, name, originX, originY, parent, parentAlpha, rotation, scaleX, scaleY, touchable, touchablility, translation, userObject, visibility, visible, width, x, y
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
act
(float delta) Updates the actor based on time.void
Cancels calls toskipToTheEnd()
.void
Removes all variables from this label.void
draw()
Draws the element.Returns aColor
instance with the color to be used onCLEARCOLOR
tokens.Returns the default token being used in this label.Similar toLabel.getText()
, but returns the original text with all the tokens unchanged.Returns theFListener
associated with this label.Returns anObjectMap
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.void
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsElement.invalidate()
on any each child whose width or height has changed, and callsElement.validate()
on each child.void
Parses all tokens of this label.void
pause()
Pauses this label's character progression.boolean
remove()
Removes this actor from its parent, if it has a parent.void
restart()
Restarts this label with the original text and starts the char progression right away.void
restart
(CharSequence newText) Restarts this label with the given text and starts the char progression right away.protected void
Restores the original text with all tokens unchanged to this label.void
resume()
Resumes this label's character progression.protected void
Copies the content ofLabel.getText()
to theStringBuilder
containing the original text with all tokens unchanged.void
setDefaultToken
(String defaultToken) Sets the default token being used in this label.void
setForceMarkupColor
(boolean forceMarkupColor) Sets whether or not this instance should enable markup color by force.void
setText
(CharSequence newText) Modifies the text of this label.protected void
setText
(CharSequence newText, boolean modifyOriginalText) Sets the text of this label.void
setTypingListener
(FListener listener) Sets theFListener
associated with this label, ornull
to remove the current one.void
setVariable
(String var, String value) Registers a variable and its respective replacement value to this label.void
setVariables
(ObjectMap<String, String> variableMap) Registers a set of variables and their respective replacement values to this label.void
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.Methods inherited from class arc.scene.ui.Label
getFontCache, getFontScaleX, getFontScaleY, getGlyphLayout, getLabelAlign, getLineAlign, getPrefHeight, getPrefWidth, getStyle, getText, invalidate, setAlignment, setAlignment, setEllipsis, setEllipsis, setFontScale, setFontScale, setFontScaleX, setFontScaleY, setStyle, setText, setWrap, textEquals, toString
Methods inherited from class arc.scene.Element
actions, addAction, addCaptureListener, addListener, change, changed, clear, clearActions, clearListeners, clicked, clicked, clicked, clicked, clipBegin, clipBegin, clipEnd, dragged, exited, fire, fireClick, getActions, getCaptureListeners, getHeight, getListeners, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getRight, getRotation, getScene, getTop, getWidth, getX, getY, getZIndex, hasActions, hasKeyboard, hasMouse, hasParent, hasScroll, hit, hovered, invalidateHierarchy, isAscendantOf, isDescendantOf, isDescendantOf, isTouchable, keepInStage, keyDown, keyDown, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, needsLayout, notify, pack, parentToLocalCoordinates, released, removeAction, removeCaptureListener, removeListener, requestKeyboard, requestScroll, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, scrolled, setBounds, setColor, setColor, setFillParent, setHeight, setLayoutEnabled, setOrigin, setOrigin, setPosition, setPosition, setRotation, setRotationOrigin, setScale, setScale, setScene, setSize, setSize, setTranslation, setWidth, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, tapped, toBack, toFront, touchable, update, updateVisibility, validate, visible
-
Field Details
-
tokenEntries
-
-
Constructor Details
-
FLabel
-
-
Method Details
-
setText
Modifies the text of this label. If the char progression is already running, it's highly recommended to userestart(CharSequence)
instead.- Overrides:
setText
in classLabel
- Parameters:
newText
- May be null, "" will be used. If this text starts with '$' or '@', this label will look inCore.bundle
for matching text.
-
setText
Sets the text of this label.- Parameters:
modifyOriginalText
- Flag determining if the original text should be modified as well. Iffalse
, only the display text is changed while the original text is untouched.- See Also:
-
getOriginalText
Similar toLabel.getText()
, but returns the original text with all the tokens unchanged. -
saveOriginalText
protected void saveOriginalText()Copies the content ofLabel.getText()
to theStringBuilder
containing the original text with all tokens unchanged. -
restoreOriginalText
protected void restoreOriginalText()Restores the original text with all tokens unchanged to this label. Make sure to callparseTokens()
to parse the tokens again. -
getTypingListener
Returns theFListener
associated with this label. May benull
. -
setTypingListener
Sets theFListener
associated with this label, ornull
to remove the current one. -
getClearColor
Returns aColor
instance with the color to be used onCLEARCOLOR
tokens. Modify this instance to change the token color. Default value is specified byFConfig
.- See Also:
-
setForceMarkupColor
public void setForceMarkupColor(boolean forceMarkupColor) Sets whether or not this instance should enable markup color by force.- See Also:
-
getDefaultToken
Returns the default token being used in this label. Defaults to empty string. -
setDefaultToken
Sets the default token being used in this label. This token will be used before the label's text, and after each {RESET} call. Useful if you want a certain token to be active at all times without having to type it all the time. -
parseTokens
public void parseTokens()Parses all tokens of this label. Use this after setting the text and any variables that should be replaced. -
skipToTheEnd
public void skipToTheEnd()Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long. Ignores all subsequent events by default. -
skipToTheEnd
public void skipToTheEnd(boolean ignoreEvents) Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long.- Parameters:
ignoreEvents
- Iftrue
, skipped events won't be reported to the listener.
-
skipToTheEnd
public void skipToTheEnd(boolean ignoreEvents, boolean ignoreEffects) Skips the char progression to the end, showing the entire label. Useful for when users don't want to wait for too long.- Parameters:
ignoreEvents
- Iftrue
, skipped events won't be reported to the listener.ignoreEffects
- Iftrue
, all text effects will be instantly cancelled.
-
cancelSkipping
public void cancelSkipping()Cancels calls toskipToTheEnd()
. Useful if you need to restore the label's normal behavior at some event after skipping. -
isPaused
public boolean isPaused()Returns whether or not this label is paused. -
pause
public void pause()Pauses this label's character progression. -
resume
public void resume()Resumes this label's character progression. -
hasEnded
public boolean hasEnded()Returns whether or not this label's char progression has ended. -
restart
public void restart()Restarts this label with the original text and starts the char progression right away. All tokens are automatically parsed. -
restart
Restarts this label with the given text and starts the char progression right away. All tokens are automatically parsed. -
getVariables
Returns anObjectMap
with all the variable names and their respective replacement values. -
setVariable
Registers a variable and its respective replacement value to this label. -
setVariables
Registers a set of variables and their respective replacement values to this label. -
clearVariables
public void clearVariables()Removes all variables from this label. -
act
public void act(float delta) Description copied from class:Element
Updates the actor based on time. Typically this is called each frame byScene.act(float)
.The default implementation calls
Action.act(float)
on each action and removes actions that are complete. -
remove
public boolean remove()Description copied from class:Element
Removes this actor from its parent, if it has a parent. -
layout
public void layout()Description copied from class:Element
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsElement.invalidate()
on any each child whose width or height has changed, and callsElement.validate()
on each child. This method should almost never be called directly, insteadElement.validate()
should be used. -
draw
public void draw()Description copied from class:Element
Draws the element. Does nothing by default.
-