Class Configuration

java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.app.utilities.Configuration

public class Configuration extends Object
Configuration class for the App class. Stores all the settings used by the App class.
  • Constructor Details

    • Configuration

      public Configuration(boolean isMusicOn, EnumMap<Actions,Controller.Key> userKeyBindings)
      Constructor for the Configuration class.
      Parameters:
      isMusicOn - Whether the music is on or off.
      userKeyBindings - The key bindings for the game.
    • Configuration

      public Configuration(boolean isMusicOn, String texturePack, int viewDistance, EnumMap<Actions,Controller.Key> userKeyBindings)
      Constructor for the Configuration class.
      Parameters:
      isMusicOn - Whether the music is on or off.
      texturePack - The texture pack for the game.
      viewDistance - The view distance for the game.
      userKeyBindings - The key bindings for the game.
  • Method Details

    • getDefaultConfiguration

      public static Configuration getDefaultConfiguration()
      Gets the default configuration if it fails to read default config file.
      Returns:
      the default configuration
    • update

      public void update(App app)
      Updates the configuration.
      Parameters:
      app - The App object that the configuration will be controlling.
    • setKeyBinding

      public void setKeyBinding(Actions action, Controller.Key key)
      Sets the key binding for the action.
      Parameters:
      action - the action to set key binding
      key - the key to set
    • getKeyBinding

      public Controller.Key getKeyBinding(Actions action)
      Gets the key binding for the action.
      Parameters:
      action - The action to get the key binding for.
      Returns:
      the key binding for the action
    • getUserKeyBindings

      public EnumMap<Actions,Controller.Key> getUserKeyBindings()
      Gets the list of action key bindings.
      Returns:
      the list of action key bindings
    • checkKeyBinding

      public boolean checkKeyBinding(int modifier, int key)
      Check if this key combo is already bound to an action.
      Parameters:
      modifier - The key modifier
      key - the key code
      Returns:
      true if the key is bound to an action, false otherwise
    • isMusicOn

      public boolean isMusicOn()
      Checks if the user is playing music.
      Returns:
      true if the user is playing music, false otherwise
    • setMusicOn

      public void setMusicOn(boolean musicOn)
      Sets playing music to true or false.
      Parameters:
      musicOn - true if music is to be played, false otherwise
    • getTexturePack

      public String getTexturePack()
      Gets the texture pack.
      Returns:
      the texture pack
    • getViewDistance

      public int getViewDistance()
      Gets the view distance.
      Returns:
      the view distance
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • save

      public void save(App app)
      saves the configuration to a file.
      Parameters:
      app - the app object