Package com.skloch.game
Class DialogueBox
java.lang.Object
com.skloch.game.DialogueBox
A class to display a dialogue box for text and options on the screen.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
A class displaying a little selction box to the user when an input is needed in dialog -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate 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 DialogueBox.SelectBox
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 -
Method Summary
Modifier and TypeMethodDescriptionprivate void
advanceText
(EventManager eventManager) Continues on to the next bit of text, or closes the window if the end is reachedvoid
enter
(EventManager eventManager) Pressing 'confirm' on the dialogue box Either selects the choice if the selectbox is open, or advances text if notfloat
Returns the height of the main dialogue screen widgetReturns the created selectbox classfloat
getWidth()
Returns the width of the main dialogue screen widgetcom.badlogic.gdx.scenes.scene2d.ui.Window
Gets the window widget of the dialogue boxvoid
hide()
Hides the dialogue box and all of its elementsvoid
Hides just the selectbox windowvoid
initialiseLabelText
(String text) Formats the text to be displayed on a label widget.boolean
Checks if the main dialogue box is visiblevoid
scrollText
(float speed) void
setPos
(float x, float y) Sets the dialogue box and all its elements to a position onscreenvoid
Sets the text to be displayed on the dialogue box, automatically wraps it correctlyvoid
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 displayingvoid
show()
Makes the dialogue box visible, along with any elements that need to be shown
-
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
-
textLines
-
linePointer
private int linePointer -
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 cornery
- The y coordinate
-
setText
Sets the text to be displayed on the dialogue box, automatically wraps it correctly- Parameters:
text
-
-
setText
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 displayeventKey
- The event key to be triggered
-
scrollText
public void scrollText(float speed) -
initialiseLabelText
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
Pressing 'confirm' on the dialogue box Either selects the choice if the selectbox is open, or advances text if not -
advanceText
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
Returns the created selectbox class- Returns:
- A SelectBox class
-