Class DialogueBox

java.lang.Object
com.skloch.game.DialogueBox

public class DialogueBox extends Object
A class to display a dialogue box for text and options on the screen.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) class 
    A class displaying a little selction box to the user when an input is needed in dialog
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private com.badlogic.gdx.scenes.scene2d.ui.Table
     
    private com.badlogic.gdx.scenes.scene2d.ui.Window
     
    private String
     
    private int
     
    private final int
     
    private boolean
     
     
    private com.badlogic.gdx.scenes.scene2d.ui.Skin
     
    private float
     
    private com.badlogic.gdx.scenes.scene2d.ui.Label
     
    private com.badlogic.gdx.utils.Array<String>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DialogueBox(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    advanceText(EventManager eventManager)
    Continues on to the next bit of text, or closes the window if the end is reached
    void
    enter(EventManager eventManager)
    Pressing 'confirm' on the dialogue box Either selects the choice if the selectbox is open, or advances text if not
    float
    Returns the height of the main dialogue screen widget
    Returns the created selectbox class
    float
    Returns the width of the main dialogue screen widget
    com.badlogic.gdx.scenes.scene2d.ui.Window
    Gets the window widget of the dialogue box
    void
    Hides the dialogue box and all of its elements
    void
    Hides just the selectbox window
    void
    Formats the text to be displayed on a label widget.
    boolean
    Checks if the main dialogue box is visible
    void
    scrollText(float speed)
     
    void
    setPos(float x, float y)
    Sets the dialogue box and all its elements to a position onscreen
    void
    Sets the text to be displayed on the dialogue box, automatically wraps it correctly
    void
    setText(String text, String eventKey)
    Sets the text to be displayed on the dialogue box, automatically wraps it correctly Additionally, schedules an event to be called after the text is done displaying
    void
    Makes the dialogue box visible, along with any elements that need to be shown

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dialogueWindow

      private com.badlogic.gdx.scenes.scene2d.ui.Window dialogueWindow
    • dialogueTable

      private com.badlogic.gdx.scenes.scene2d.ui.Table dialogueTable
    • textLabel

      private com.badlogic.gdx.scenes.scene2d.ui.Label textLabel
    • skin

      private com.badlogic.gdx.scenes.scene2d.ui.Skin skin
    • MAXCHARS

      private final int MAXCHARS
    • selectBox

      private DialogueBox.SelectBox selectBox
    • textLines

      private com.badlogic.gdx.utils.Array<String> textLines
    • linePointer

      private int linePointer
    • eventKey

      private String eventKey
    • textCounter

      private float textCounter
    • scrollingText

      private boolean scrollingText
  • Constructor Details

    • DialogueBox

      public DialogueBox(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
  • Method Details

    • setPos

      public void setPos(float x, float y)
      Sets the dialogue box and all its elements to a position onscreen
      Parameters:
      x - The x coordinate of the bottom left corner
      y - The y coordinate
    • setText

      public void setText(String text)
      Sets the text to be displayed on the dialogue box, automatically wraps it correctly
      Parameters:
      text -
    • setText

      public void setText(String text, String eventKey)
      Sets the text to be displayed on the dialogue box, automatically wraps it correctly Additionally, schedules an event to be called after the text is done displaying
      Parameters:
      text - THe text to display
      eventKey - The event key to be triggered
    • scrollText

      public void scrollText(float speed)
    • initialiseLabelText

      public void initialiseLabelText(String text)
      Formats the text to be displayed on a label widget. Adds a newline character every MAXCHARS num of characters accounts for any occuring linebreaks to take use of the size of the most space possible. Stores the formatted text in 3 chunks, which are then queued up to be pushed to the label whenever the user presses e.
      Parameters:
      text - The text to format and push to the label
    • show

      public void show()
      Makes the dialogue box visible, along with any elements that need to be shown
    • hide

      public void hide()
      Hides the dialogue box and all of its elements
    • enter

      public void enter(EventManager eventManager)
      Pressing 'confirm' on the dialogue box Either selects the choice if the selectbox is open, or advances text if not
    • advanceText

      private void advanceText(EventManager eventManager)
      Continues on to the next bit of text, or closes the window if the end is reached
    • hideSelectBox

      public void hideSelectBox()
      Hides just the selectbox window
    • isVisible

      public boolean isVisible()
      Checks if the main dialogue box is visible
      Returns:
      true if it is visible, false otherwise
    • getWindow

      public com.badlogic.gdx.scenes.scene2d.ui.Window getWindow()
      Gets the window widget of the dialogue box
      Returns:
      A window widget
    • getWidth

      public float getWidth()
      Returns the width of the main dialogue screen widget
      Returns:
      The width
    • getHeight

      public float getHeight()
      Returns the height of the main dialogue screen widget
      Returns:
      The height
    • getSelectBox

      public DialogueBox.SelectBox getSelectBox()
      Returns the created selectbox class
      Returns:
      A SelectBox class