Package com.csse3200.game.minigames
Class MinigameLeaderboard
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.minigames.MinigameLeaderboard
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
Represents the leaderboard display for mini-games in the game.
It allows users to view the top scores for different mini-games
(Snake, Bird, Fish) and switch between them. The class interacts with
the PlayFab service to retrieve the leaderboard data and displays it
to the user.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
ConstructorsConstructorDescriptionMinigameLeaderboard
(MainMenuDisplay mainMenuDisplay) Constructor for MinigameLeaderboard. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Releases all resources of Disposable object.protected void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the component.Retrieves the list of high scores currently displayed on the leaderboard.Retrieves the list of usernames currently displayed on the leaderboard.float
Gets the Z-index used for rendering this UI component.void
Initializes the table layout for the leaderboard, including setting the background, size, and title label.com.badlogic.gdx.scenes.scene2d.ui.Table
Creates and returns the main table for the leaderboard UI.void
refreshLeaderboard
(String name) Refreshes the leaderboard data for the specified mini-game.void
Updates the leaderboard data by fetching the latest usernames and scores from the PlayFab service and refreshing the UI.Methods inherited from class com.csse3200.game.ui.UIComponent
create, getLayer, setStage
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Constructor Details
-
Method Details
-
makeLeaderboardTable
public com.badlogic.gdx.scenes.scene2d.ui.Table makeLeaderboardTable()Creates and returns the main table for the leaderboard UI. This includes loading textures, setting up the table layout, and adding buttons for user interaction.- Returns:
- A Table containing the leaderboard UI elements
-
initializeTable
public void initializeTable()Initializes the table layout for the leaderboard, including setting the background, size, and title label. -
updateLeaderboard
public void updateLeaderboard()Updates the leaderboard data by fetching the latest usernames and scores from the PlayFab service and refreshing the UI. -
refreshLeaderboard
Refreshes the leaderboard data for the specified mini-game.- Parameters:
name
- The name of the mini-game ("Snake", "Bird", "Fish", or "Current")
-
getUsernames
Retrieves the list of usernames currently displayed on the leaderboard.- Returns:
- A list of usernames
-
getHighscores
Retrieves the list of high scores currently displayed on the leaderboard.- Returns:
- A list of high scores
-
getZIndex
public float getZIndex()Gets the Z-index used for rendering this UI component.- Specified by:
getZIndex
in interfaceRenderable
- Overrides:
getZIndex
in classUIComponent
- Returns:
- The Z-index value
-
draw
protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the component. Currently not used as the drawing is handled by the Scene2D tables.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- The SpriteBatch used for drawing
-
dispose
public void dispose()Releases all resources of Disposable object.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-