Save

This contains the source code documentation of the class subsystem_Save.

subsystem_Save

Inherits: DialogicSubsystem

Subsystem to save and load game states.

Description

This subsystem has many different helper methods to save Dialogic or custom game data to named save slots. You can listen to saves via saved. \ If you want to save, you can call save.

Properties


Methods

ReturnsMethod
voidclear_game_state ( _clear_flag: int = 0 )
voidpause ( )
voidresume ( )
intsave ( slot_name: String = "", is_autosave: bool = false, thumbnail_mode: int = 1, slot_info: Dictionary = {} )
intload ( slot_name: String = "" )
intsave_file ( slot_name: String, file_name: String, data: Variant )
Variantload_file ( slot_name: String, file_name: String, default: Variant )
intset_global_info ( key: String, value: Variant )
Variantget_global_info ( key: String, default: Variant )
Stringget_encryption_password ( )
String[]get_slot_names ( )
boolhas_slot ( slot_name: String )
intdelete_slot ( slot_name: String )
intadd_empty_slot ( slot_name: String )
intreset_slot ( slot_name: String = "" )
Stringget_slot_path ( slot_name: String )
Stringget_default_slot ( )
Stringget_latest_slot ( )
intset_latest_slot ( slot_name: String )
intset_slot_info ( slot_name: String, info: Dictionary )
Dictionaryget_slot_info ( slot_name: String = "" )
voidtake_thumbnail ( )
intsave_slot_thumbnail ( slot_name: String )
ImageTextureget_slot_thumbnail ( slot_name: String )
intperform_autosave ( )

Constants

const SAVE_SLOTS_DIR = "user://dialogic/saves/"

No description available.


const AUTO_SAVE_SETTINGS = "dialogic/save/autosave"

No description available.


const AUTO_SAVE_MODE_SETTINGS = "dialogic/save/autosave_mode"

No description available.


const AUTO_SAVE_TIME_SETTINGS = "dialogic/save/autosave_delay"

No description available.


const NONE = 0

No description available.


const TAKE_AND_STORE = 1

No description available.


const STORE_ONLY = 2

No description available.


const ON_TIMELINE_JUMPS = 0

No description available.


const ON_TIMER = 1

No description available.


const ON_TEXT_EVENT = 2

No description available.


Signals

signal saved ( info: Dictionary )

Emitted when a save happened with the following info: Key | Value Type | Value ----------- | ------------- | ----- slot_name | String | The name of the slot that the game state was saved to. is_autosave | bool | true, if the save was an autosave.


Property Descriptions

var latest_thumbnail = null

No description available.


var autosave_enabled = false

Whether the auto-save feature is enabled. The initial value can be set in the project settings via th Dialogic editor. This can be toggled during the game.


var autosave_mode = 0

Under what conditions the auto-save feature will trigger if autosave_enabled is true.


var autosave_time = 60

After what time interval the auto-save feature will trigger if autosave_enabled is true and autosave_mode is AutoSaveMode.ON_TIMER.


var autosave_timer = new()

################################################################################################## Reference to the autosave timer.


Method Descriptions

func clear_game_state ( _clear_flag: int = 0 ) ⇒ void

Built-in, called by DialogicGameHandler.


func pause ( ) ⇒ void

Built-in, called by DialogicGameHandler.


func resume ( ) ⇒ void

Built-in, called by DialogicGameHandler.


func save ( slot_name: String = "", is_autosave: bool = false, thumbnail_mode: int = 1, slot_info: Dictionary = {} ) ⇒ int

Saves the current state to the given slot. If no slot is given, the default slot is used. You can change this name in the Dialogic editor. If you want to save to the last used slot, you can get its slot name with the [method get_latest_slot()] method.


func load ( slot_name: String = "" ) ⇒ int

Loads all info from the given slot in the DialogicGameHandler (Dialogic Autoload). If no slot is given, the default slot is used. To check if something is saved in that slot use has_slot(). If the slot does not exist, this method will fail.


func save_file ( slot_name: String, file_name: String, data: Variant ) ⇒ int

Saves a variable to a file in the given slot. Be aware, the slot_name will be used as a filesystem folder name. Some operating systems do not support every character in folder names. It is recommended to use only letters, numbers, and underscores. This method allows you to build your own save and load system. You may be looking for the simple save method to save the game state.


func load_file ( slot_name: String, file_name: String, default: Variant ) ⇒ Variant

Loads a file using slot_name and returns the contained info. This method allows you to build your own save and load system. You may be looking for the simple load method to load the game state.


func set_global_info ( key: String, value: Variant ) ⇒ int

Data set in global info can be accessed unrelated to the save slots. For instance, you may want to store game settings in here, as they affect the game globally unrelated to the slot used.


func get_global_info ( key: String, default: Variant ) ⇒ Variant

Access the data unrelated to a save slot. First, the data must have been set with set_global_info.


func get_encryption_password ( ) ⇒ String

Gets the encryption password from the project settings if it has been set. If no password has been set, an empty string is returned.


func get_slot_names ( ) ⇒ String[]

################################################################################################## Returns a list of all available slots. Useful for iterating over all slots, e.g., when building a UI with all save slots.


func has_slot ( slot_name: String ) ⇒ bool

Returns true if the given slot exists.


func delete_slot ( slot_name: String ) ⇒ int

Removes all the given slot along with all it's info/files.


func add_empty_slot ( slot_name: String ) ⇒ int

This adds a new save folder with the given name


func reset_slot ( slot_name: String = "" ) ⇒ int

Reset the state of the given save folder (or default)


func get_slot_path ( slot_name: String ) ⇒ String

Returns the full path to the given slot folder


func get_default_slot ( ) ⇒ String

Returns the default slot name defined in the dialogic settings


func get_latest_slot ( ) ⇒ String

Returns the latest slot or empty if nothing was saved yet


func set_latest_slot ( slot_name: String ) ⇒ int

No description available.


func set_slot_info ( slot_name: String, info: Dictionary ) ⇒ int

No description available.


func get_slot_info ( slot_name: String = "" ) ⇒ Dictionary

No description available.


func take_thumbnail ( ) ⇒ void

This method creates a thumbnail of the current game view, it allows to save the game without having the UI on the save slot image. The thumbnail will be stored in latest_thumbnail. Call this method before opening your save & load menu. After that, call save with [constant ThumbnailMode.STORE_ONLY]. The save will automatically use the stored thumbnail.


func save_slot_thumbnail ( slot_name: String ) ⇒ int

No need to call from outside. Used to store the latest thumbnail to the given slot.


func get_slot_thumbnail ( slot_name: String ) ⇒ ImageTexture

Returns the thumbnail of the given slot.


func perform_autosave ( ) ⇒ int

Perform an autosave. This method will be called automatically if the auto-save mode is enabled.