Class MinigameLeaderboard

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class MinigameLeaderboard extends UIComponent
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.
  • Constructor Details

    • MinigameLeaderboard

      public MinigameLeaderboard(MainMenuDisplay mainMenuDisplay)
      Constructor for MinigameLeaderboard. Initializes the PlayFab service with the provided TitleId and sets up the main display.
      Parameters:
      mainMenuDisplay - The main menu display to interact with
  • 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

      public void refreshLeaderboard(String name)
      Refreshes the leaderboard data for the specified mini-game.
      Parameters:
      name - The name of the mini-game ("Snake", "Bird", "Fish", or "Current")
    • getUsernames

      public ArrayList<String> getUsernames()
      Retrieves the list of usernames currently displayed on the leaderboard.
      Returns:
      A list of usernames
    • getHighscores

      public ArrayList<String> 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 interface Renderable
      Overrides:
      getZIndex in class UIComponent
      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 class RenderComponent
      Parameters:
      batch - The SpriteBatch used for drawing
    • dispose

      public void dispose()
      Releases all resources of Disposable object.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent