Package arc.flabel

Class FLabel


public class FLabel extends Label
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
  • Field Details

    • tokenEntries

      protected final Seq<arc.flabel.FParser.TokenEntry> tokenEntries
  • Constructor Details

  • Method Details

    • setText

      public void setText(CharSequence newText)
      Modifies the text of this label. If the char progression is already running, it's highly recommended to use restart(CharSequence) instead.
      Overrides:
      setText in class Label
      Parameters:
      newText - May be null, "" will be used. If this text starts with '$' or '@', this label will look in Core.bundle for matching text.
    • setText

      protected void setText(CharSequence newText, boolean modifyOriginalText)
      Sets the text of this label.
      Parameters:
      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.
      See Also:
    • getOriginalText

      public StringBuilder getOriginalText()
      Similar to Label.getText(), but returns the original text with all the tokens unchanged.
    • saveOriginalText

      protected void saveOriginalText()
      Copies the content of Label.getText() to the StringBuilder 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 call parseTokens() to parse the tokens again.
    • getTypingListener

      public FListener getTypingListener()
      Returns the FListener associated with this label. May be null.
    • setTypingListener

      public void setTypingListener(FListener listener)
      Sets the FListener associated with this label, or null to remove the current one.
    • getClearColor

      public Color getClearColor()
      Returns a Color instance with the color to be used on CLEARCOLOR tokens. Modify this instance to change the token color. Default value is specified by FConfig.
      See Also:
    • setForceMarkupColor

      public void setForceMarkupColor(boolean forceMarkupColor)
      Sets whether or not this instance should enable markup color by force.
      See Also:
    • getDefaultToken

      public String getDefaultToken()
      Returns the default token being used in this label. Defaults to empty string.
    • setDefaultToken

      public void setDefaultToken(String defaultToken)
      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 - If true, 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 - If true, skipped events won't be reported to the listener.
      ignoreEffects - If true, all text effects will be instantly cancelled.
    • cancelSkipping

      public void cancelSkipping()
      Cancels calls to skipToTheEnd(). 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

      public void restart(CharSequence newText)
      Restarts this label with the given text and starts the char progression right away. All tokens are automatically parsed.
    • getVariables

      public ObjectMap<String,String> getVariables()
      Returns an ObjectMap with all the variable names and their respective replacement values.
    • setVariable

      public void setVariable(String var, String value)
      Registers a variable and its respective replacement value to this label.
    • setVariables

      public void setVariables(ObjectMap<String,String> variableMap)
      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 by Scene.act(float).

      The default implementation calls Action.act(float) on each action and removes actions that are complete.

      Overrides:
      act in class Element
      Parameters:
      delta - Time in seconds since the last frame.
    • remove

      public boolean remove()
      Description copied from class: Element
      Removes this actor from its parent, if it has a parent.
      Overrides:
      remove in class Element
      See Also:
    • 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, calls Element.invalidate() on any each child whose width or height has changed, and calls Element.validate() on each child. This method should almost never be called directly, instead Element.validate() should be used.
      Overrides:
      layout in class Label
    • draw

      public void draw()
      Description copied from class: Element
      Draws the element. Does nothing by default.
      Overrides:
      draw in class Label