Class PreferencesManager
- All Implemented Interfaces:
Disposable
,Manager
To simplify the migration progress, we must load all of the data listed above into a single common storage format (basically an ObjectMap of strings per type of properties). What kind of data we must support to load legacy properties: - Legacy encoded local property files - Base64 encoded byte arrays of properties (from cloud saves and backups)
New storage format: deflated Json string with key-value pairs for individual properties If transferred over the network - encoded in base64 (cloud saves / backups)Local properties are no longer stored in LibGDX-provided Properties. Instead, properties are stored locally to the game: - saves/settings.bin - for Settings properties (also stores user session) - saves/progress.bin - for Progress properties Steam Cloud synchronizes saves/ folder. If another progress save file will be required later (for example, seasonal or server-sync progress), it can be stored as a file with a different name (no need to manage saves on a different screen)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
Nested classes/interfaces inherited from interface com.prineside.tdi2.Manager
Manager.ManagerAdapter, Manager.ManagerWithListeners<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
dispose()
Releases all resources of this object.void
fromBase64
(String dataStr) void
fromBytes
(byte[] data, int offset, int size) static String
static String
static String
static String
static String
static String
void
loadFromUrl
(String url, ObjectConsumer<Boolean> cb) Legacy Used to restore backups of properties Uses loadFromCompactBase64() internallyvoid
void
void
Reset progress in Settings - Removes progress-related preferences (local files and runtime data) - Deletes all replays - Resets cloud save slot in settings preferences - Removes issued items log - Finally reapplies preferences (event)void
Save all preferences to files immediatelyvoid
setup()
Вызывается, когда объекты всех менеджеров созданы и можно к ним обращатьсяMethods inherited from class com.prineside.tdi2.Manager.ManagerAdapter
postRender, preRender, test
-
Field Details
-
PROGRESS_PREFS_FILE_PATH_DEV
- See Also:
-
SETTINGS_PREFS_FILE_PATH_DEV
- See Also:
-
-
Constructor Details
-
PreferencesManager
public PreferencesManager()
-
-
Method Details
-
getSettingsPrefsFilePath
-
getProgressPrefsFilePath
-
getSavesDirPath
-
getSavedGameFilePath
-
getIssuedItemsFilePath
-
getReplaysDirPath
-
setup
public void setup()Description copied from interface:Manager
Вызывается, когда объекты всех менеджеров созданы и можно к ним обращаться- Specified by:
setup
in interfaceManager
- Overrides:
setup
in classManager.ManagerAdapter
-
getLegacyPreferences
-
getPrefMapForProgressSaveFile
-
getPrefMapForSettingsSaveFile
-
getProgressPrefs
- Returns:
- progress-related preferences. Player can have multiple saved games that may be stored in cloud / backups Progress preferences contain ID of the owner (playerid) so that they can't be shared or mistakenly duplicated
-
getSettingsPrefs
- Returns:
- settings-related preferences which does not affect the progress. Usually stored locally / are device-specific and are not stored in cloud / backups For security reasons, these settings are not backed up / stored in cloud / replays since 1.9.0
-
saveNowIfRequired
public void saveNowIfRequired()Save all preferences to files immediately -
loadFromUrl
Legacy Used to restore backups of properties Uses loadFromCompactBase64() internally -
fromBase64
- Parameters:
dataStr
- legacy or new format - legacy stores all preferences. Migration will be performed if necessary, and both progress / settings preferences may be affected - new stores a single type of preferences Warning: legacy settings preferences will be ignored. Not a big deal
-
fromBytes
public void fromBytes(byte[] data, int offset, int size) -
progressPrefsToBase64
-
settingsPrefsToBase64
-
dispose
public void dispose()Description copied from interface:com.badlogic.gdx.utils.Disposable
Releases all resources of this object.- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classManager.ManagerAdapter
-
addListener
-
removeListener
-
reapplyAllPreferences
public void reapplyAllPreferences() -
resetProgress
public void resetProgress()Reset progress in Settings - Removes progress-related preferences (local files and runtime data) - Deletes all replays - Resets cloud save slot in settings preferences - Removes issued items log - Finally reapplies preferences (event)
-