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) classA 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.Tableprivate com.badlogic.gdx.scenes.scene2d.ui.Windowprivate Stringprivate intprivate final intprivate booleanprivate DialogueBox.SelectBoxprivate com.badlogic.gdx.scenes.scene2d.ui.Skinprivate floatprivate com.badlogic.gdx.scenes.scene2d.ui.Labelprivate com.badlogic.gdx.utils.Array<String> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadvanceText(EventManager eventManager) Continues on to the next bit of text, or closes the window if the end is reachedvoidenter(EventManager eventManager) Pressing 'confirm' on the dialogue box Either selects the choice if the selectbox is open, or advances text if notfloatReturns the height of the main dialogue screen widgetReturns the created selectbox classfloatgetWidth()Returns the width of the main dialogue screen widgetcom.badlogic.gdx.scenes.scene2d.ui.WindowGets the window widget of the dialogue boxvoidhide()Hides the dialogue box and all of its elementsvoidHides just the selectbox windowvoidinitialiseLabelText(String text) Formats the text to be displayed on a label widget.booleanChecks if the main dialogue box is visiblevoidscrollText(float speed) voidsetPos(float x, float y) Sets the dialogue box and all its elements to a position onscreenvoidSets the text to be displayed on the dialogue box, automatically wraps it correctlyvoidSets 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 displayingvoidshow()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
-