Package com.csse3200.game.files
Class UserSettings
java.lang.Object
com.csse3200.game.files.UserSettings
Reading, Writing, and applying user settings in the game.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Stores chosen display settings.static class
Stores custom keybind settings.static class
Stores game settings, can be serialised/deserialised. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
applySettings
(UserSettings.Settings settings) Apply the given settings without storing them.static UserSettings.Settings
get()
Get the stored user settingsstatic float
Returns the multiplier corresponding to master volume.static float
Returns the normalized music volume stored in the user settings.static void
Initialises keybinds on game startup by applying saved settings or defaultsstatic void
Resets all keybinds to their default values and saves the settings.static void
Saves the current keymap state to user settings.static void
set
(UserSettings.Settings settings, boolean applyImmediate) Set the stored user settings
-
Method Details
-
get
Get the stored user settings- Returns:
- Copy of the current settings
-
set
Set the stored user settings- Parameters:
settings
- New settings to storeapplyImmediate
- true to immediately apply new settings.
-
applySettings
Apply the given settings without storing them.- Parameters:
settings
- Settings to apply
-
saveCurrentKeybinds
public static void saveCurrentKeybinds()Saves the current keymap state to user settings. Creates a snapshot of all current keybinds and stores them as custom settings. -
resetKeybindsToDefaults
public static void resetKeybindsToDefaults()Resets all keybinds to their default values and saves the settings. Clears any custom keybind overrides and restores the original keymap. -
initialiseKeybinds
public static void initialiseKeybinds()Initialises keybinds on game startup by applying saved settings or defaults -
getMusicVolumeNormalized
public static float getMusicVolumeNormalized()Returns the normalized music volume stored in the user settings. That is, the music volume is a fraction of it's intended volume according to the master volume.- Returns:
- The normalized volume for the music.
-
getMasterVolume
public static float getMasterVolume()Returns the multiplier corresponding to master volume. All sound effects' volume should be multiplied by this float before they are played. Example: A return value of 0.5 means the user has set the master volume to 50%, and thus all sounds should be reduced by 50%.- Returns:
- The master volume
-