Class ConfigManager

java.lang.Object
com.bomber7.core.ConfigManager

public final class ConfigManager extends Object
A singleton manager responsible for loading, saving, and managing the user's configuration.

The configuration is saved locally using LibGDX's FileHandle, and is serialized via Java's ObjectOutputStream. This manager provides access to both the persistent config and a modifiable version that can be saved or discarded.

  • Method Details

    • getInstance

      public static ConfigManager getInstance()
      Retrieves the singleton instance of the ConfigManager.
      Returns:
      the single ConfigManager instance.
    • initialize

      public void initialize()
      Initializes the ConfigManager manager.

      This method must be called before any config access occurs.

    • save

      public void save()
      Saves the current config into CONFIG_FILE.
    • getConfig

      public Config getConfig()
      A getter for the modifiableConfig attribute.
      Returns:
      the current modifiableConfig attribute.
    • saveModifications

      public void saveModifications()
      Saves the modifications made to modifiableConfig into config. Saves the config file to user's local directory and resets the modifications made to modifiableConfig.
    • resetModifications

      public void resetModifications()
      Discard the changes made in the unsavedConfig.
    • isUnsaved

      public boolean isUnsaved()
      Indicates whether there is unsaved changes.
      Returns:
      true if modifiableConfig does not have the same config as config, false if they are the same.