Package tech.underoaks.coldcase.game
Class UITextureController
java.lang.Object
tech.underoaks.coldcase.game.UITextureController
This class is responsible for providing the skin for the UI elements.
-
Method Summary
Modifier and TypeMethodDescriptionstatic UITextureControllercreate(TextureFactory factory) Creates a newUITextureControllerinstance using the providedTextureFactory.static booleanexists()Checks whether aUITextureControllerinstance has been initialized.com.badlogic.gdx.scenes.scene2d.utils.DrawableReturns aDrawablerepresenting the "button down" texture.com.badlogic.gdx.math.Vector2Calculates and returns the size of a button based on the dimensions of the buttonUp texture scaled by the button size multiplier.com.badlogic.gdx.scenes.scene2d.utils.DrawableReturns aDrawablerepresenting the "button up" texture.com.badlogic.gdx.graphics.g2d.BitmapFontgetFont()Returns theBitmapFontused by the UI.static UITextureControllerReturns the singleton instance ofUITextureController.com.badlogic.gdx.scenes.scene2d.ui.ImageReturns anImageconfigured as the menu background.com.badlogic.gdx.scenes.scene2d.utils.DrawableReturns aDrawablerepresenting the reload button texture.com.badlogic.gdx.scenes.scene2d.ui.SkingetSkin()Returns theSkinused for styling UI elements.static charmapIntToLetter(int number, boolean isUpperCase) Maps an integer to a letter.
-
Method Details
-
create
Creates a newUITextureControllerinstance using the providedTextureFactory.If an instance is already initialized, this method throws an
IllegalStateException.- Parameters:
factory- theTextureFactoryused to create textures for UI elements- Returns:
- the newly created
UITextureControllerinstance - Throws:
IllegalStateException- if the UITextureController has already been initialized
-
getInstance
Returns the singleton instance ofUITextureController.If the instance has not been created yet, this method throws an
IllegalStateException.- Returns:
- the UITextureController instance
- Throws:
IllegalStateException- if the UITextureController is not initialized
-
exists
public static boolean exists()Checks whether aUITextureControllerinstance has been initialized.- Returns:
trueif a UITextureController instance exists;falseotherwise
-
getSkin
public com.badlogic.gdx.scenes.scene2d.ui.Skin getSkin()Returns theSkinused for styling UI elements.- Returns:
- the
Skininstance
-
getButtonSize
public com.badlogic.gdx.math.Vector2 getButtonSize()Calculates and returns the size of a button based on the dimensions of the buttonUp texture scaled by the button size multiplier.- Returns:
- a
Vector2containing the width and height of a button
-
getButtonUp
public com.badlogic.gdx.scenes.scene2d.utils.Drawable getButtonUp()Returns aDrawablerepresenting the "button up" texture.- Returns:
- a
Drawablefor the button up state
-
getButtonDown
public com.badlogic.gdx.scenes.scene2d.utils.Drawable getButtonDown()Returns aDrawablerepresenting the "button down" texture.- Returns:
- a
Drawablefor the button down state
-
getReloadButton
public com.badlogic.gdx.scenes.scene2d.utils.Drawable getReloadButton()Returns aDrawablerepresenting the reload button texture.- Returns:
- a
Drawablefor the reload button
-
getMenuBackground
public com.badlogic.gdx.scenes.scene2d.ui.Image getMenuBackground()Returns anImageconfigured as the menu background.The returned
Imageis set to fill its parent and uses a fill scaling mode.- Returns:
- the menu background
Image
-
getFont
public com.badlogic.gdx.graphics.g2d.BitmapFont getFont()Returns theBitmapFontused by the UI.- Returns:
- the
BitmapFontinstance
-
mapIntToLetter
public static char mapIntToLetter(int number, boolean isUpperCase) Maps an integer to a letter.- Parameters:
number- The number to map to a letter. Must be between 1 and 26. 1 corresponds to 'a' or 'A', 2 to 'b' or 'B', etc.isUpperCase- Whether the letter should be uppercase.- Returns:
- The letter corresponding to the number.
- Throws:
IllegalArgumentException- If the number is not between 1 and 26.
-