Package com.bomber7.core
Class ConfigManager
java.lang.Object
com.bomber7.core.ConfigManager
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 Summary
Modifier and TypeMethodDescriptionA getter for themodifiableConfigattribute.static ConfigManagerRetrieves the singleton instance of theConfigManager.voidInitializes the ConfigManager manager.booleanIndicates whether there is unsaved changes.voidDiscard the changes made in the unsavedConfig.voidsave()Saves the current config into CONFIG_FILE.voidSaves the modifications made tomodifiableConfigintoconfig.
-
Method Details
-
getInstance
Retrieves the singleton instance of theConfigManager.- Returns:
- the single
ConfigManagerinstance.
-
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
A getter for themodifiableConfigattribute.- Returns:
- the current modifiableConfig attribute.
-
saveModifications
public void saveModifications()Saves the modifications made tomodifiableConfigintoconfig. Saves the config file to user's local directory and resets the modifications made tomodifiableConfig. -
resetModifications
public void resetModifications()Discard the changes made in the unsavedConfig. -
isUnsaved
public boolean isUnsaved()Indicates whether there is unsaved changes.- Returns:
trueifmodifiableConfigdoes not have the same config asconfig,falseif they are the same.
-