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 themodifiableConfig
attribute.static ConfigManager
Retrieves the singleton instance of theConfigManager
.void
Initializes the ConfigManager manager.boolean
Indicates whether there is unsaved changes.void
Discard the changes made in the unsavedConfig.void
save()
Saves the current config into CONFIG_FILE.void
Saves the modifications made tomodifiableConfig
intoconfig
.
-
Method Details
-
getInstance
Retrieves the singleton instance of theConfigManager
.- 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
A getter for themodifiableConfig
attribute.- Returns:
- the current modifiableConfig attribute.
-
saveModifications
public void saveModifications()Saves the modifications made tomodifiableConfig
intoconfig
. 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:
true
ifmodifiableConfig
does not have the same config asconfig
,false
if they are the same.
-