Package com.csse3200.game.gamestate
Class SaveHandler
java.lang.Object
com.csse3200.game.gamestate.SaveHandler
Wrapper for FileLoader that has default interactions with various data structs.
Saves and loads specified files.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(Class<?> className, String dir, FileLoader.Location location) Clear all data from JSON files.static SaveHandler
Gets the single instance of the SaveHandler singleton if it exists or creates one if it doesn't.void
load
(Class<?> className, String dir, FileLoader.Location location) Load all fields to a specified class from JSON files.void
save
(Class<?> className, String dir, FileLoader.Location location) Save all fields in the specified class to JSON files.
-
Method Details
-
save
Save all fields in the specified class to JSON files.- Parameters:
className
- class to use as saves. For game state (not shared between new games), use GameState.class. For achievements (shared between new games), use Achievements.class.dir
- the directory in assets for the saves to be located in. For game state (not shared between new games), use "saves". For achievements (shared between new games), use "saves/achievements"location
- Libgdx location to save to.- See Also:
-
load
Load all fields to a specified class from JSON files.- Parameters:
className
- class to use as saves. For game state (not shared between new games), use GameState.class. For achievements (shared between new games), use Achievements.class.dir
- the directory in assets for the saves to be located in. For game state (not shared between new games), use "saves". For achievements (shared between new games), use "saves/achievements"location
- Libgdx location to load from.- See Also:
-
delete
Clear all data from JSON files.- Parameters:
className
- class to use as saves. For game state (not shared between new games), use GameState.class. For achievements (shared between new games), use Achievements.class.dir
- the directory in assets for the saves to be located in. For game state (not shared between new games), use "saves". For achievements (shared between new games), use "saves/achievements"location
- Libgdx location to delete from.- See Also:
-
getInstance
Gets the single instance of the SaveHandler singleton if it exists or creates one if it doesn't.- Returns:
- the SaveHandler instance.
-