Class UserSettings

java.lang.Object
com.csse3200.game.files.UserSettings

public class UserSettings extends Object
Reading, Writing, and applying user settings in the game.
  • Method Details

    • get

      public static UserSettings.Settings get()
      Get the stored user settings
      Returns:
      Copy of the current settings
    • set

      public static void set(UserSettings.Settings settings, boolean applyImmediate)
      Set the stored user settings
      Parameters:
      settings - New settings to store
      applyImmediate - true to immediately apply new settings.
    • applySettings

      public static void applySettings(UserSettings.Settings settings)
      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