Class Configuration
java.lang.Object
nz.ac.vuw.ecs.swen225.gp6.app.utilities.Configuration
Configuration class for the App class. Stores all the settings used by the App class.
-
Constructor Summary
ConstructorsConstructorDescriptionConfiguration(boolean isMusicOn, String texturePack, int viewDistance, EnumMap<Actions, Controller.Key> userKeyBindings) Constructor for the Configuration class.Configuration(boolean isMusicOn, EnumMap<Actions, Controller.Key> userKeyBindings) Constructor for the Configuration class. -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckKeyBinding(int modifier, int key) Check if this key combo is already bound to an action.static ConfigurationGets the default configuration if it fails to read default config file.getKeyBinding(Actions action) Gets the key binding for the action.Gets the texture pack.Gets the list of action key bindings.intGets the view distance.booleanChecks if the user is playing music.voidsaves the configuration to a file.voidsetKeyBinding(Actions action, Controller.Key key) Sets the key binding for the action.voidsetMusicOn(boolean musicOn) Sets playing music to true or false.toString()voidUpdates the configuration.
-
Constructor Details
-
Configuration
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
Gets the default configuration if it fails to read default config file.- Returns:
- the default configuration
-
update
Updates the configuration.- Parameters:
app- The App object that the configuration will be controlling.
-
setKeyBinding
Sets the key binding for the action.- Parameters:
action- the action to set key bindingkey- the key to set
-
getKeyBinding
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
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 modifierkey- 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
Gets the texture pack.- Returns:
- the texture pack
-
getViewDistance
public int getViewDistance()Gets the view distance.- Returns:
- the view distance
-
toString
-
save
saves the configuration to a file.- Parameters:
app- the app object
-