Package cs.eng1.piazzapanic.ui
Class ButtonManager
- java.lang.Object
-
- cs.eng1.piazzapanic.ui.ButtonManager
-
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
public class ButtonManager extends java.lang.Object implements com.badlogic.gdx.utils.Disposable
A utility which generates UI buttons with the correct background images given specific text, images and colours.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ButtonManager.ButtonColour
-
Constructor Summary
Constructors Constructor Description ButtonManager(FontManager fontManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.badlogic.gdx.scenes.scene2d.ui.CheckBox
createCheckbox(java.lang.String text, ButtonManager.ButtonColour colour)
Create a text button with certain parameters.com.badlogic.gdx.scenes.scene2d.ui.ImageButton
createImageButton(com.badlogic.gdx.scenes.scene2d.utils.Drawable image, ButtonManager.ButtonColour colour, float yPressedOffset)
Create an image button with certain parameters.com.badlogic.gdx.scenes.scene2d.ui.TextButton
createTextButton(java.lang.String text, ButtonManager.ButtonColour colour)
Create a text button with certain parameters.void
dispose()
Properly dispose of loaded textures from memory.
-
-
-
Constructor Detail
-
ButtonManager
public ButtonManager(FontManager fontManager)
- Parameters:
fontManager
- the fontManager from which this class can get the right fonts required.
-
-
Method Detail
-
createTextButton
public com.badlogic.gdx.scenes.scene2d.ui.TextButton createTextButton(java.lang.String text, ButtonManager.ButtonColour colour)
Create a text button with certain parameters.- Parameters:
text
- The string to display on the button.colour
- The colour of the base button.- Returns:
- The text button constructed based on the input.
-
createImageButton
public com.badlogic.gdx.scenes.scene2d.ui.ImageButton createImageButton(com.badlogic.gdx.scenes.scene2d.utils.Drawable image, ButtonManager.ButtonColour colour, float yPressedOffset)
Create an image button with certain parameters.- Parameters:
image
- The image to display on top of the button. It can have transparency.colour
- The colour of the base button.yPressedOffset
- The amount to move the top image when the button has been pressed.- Returns:
- The image button constructed based on the input with a default of 0 padding.
-
createCheckbox
public com.badlogic.gdx.scenes.scene2d.ui.CheckBox createCheckbox(java.lang.String text, ButtonManager.ButtonColour colour)
Create a text button with certain parameters.- Parameters:
text
- The string to display on the button.colour
- The colour of the base button.- Returns:
- The text button constructed based on the input.
-
dispose
public void dispose()
Properly dispose of loaded textures from memory.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
-