Implement custom data save in settings and savegames (#484)
This commit is contained in:
@@ -282,6 +282,20 @@ func hide_main_menu():
|
||||
pass
|
||||
|
||||
|
||||
# Custom function that is meant to apply custom settings. Called right after
|
||||
# Escoria settings file was loaded.
|
||||
func apply_custom_settings(custom_settings: Dictionary):
|
||||
pass
|
||||
|
||||
|
||||
# Custom function automatically called when save game is created.
|
||||
#
|
||||
# *Returns* A Dictionary containing the custom data to be saved within the
|
||||
# game file.
|
||||
func get_custom_data() -> Dictionary:
|
||||
return {}
|
||||
|
||||
|
||||
# Shows the crash popup when a crash occurs
|
||||
#
|
||||
# #### Parameters
|
||||
|
||||
@@ -154,6 +154,8 @@ func _do_save_game(p_savename: String) -> ESCSaveGame:
|
||||
escoria.globals_manager.save_game(save_game)
|
||||
escoria.object_manager.save_game(save_game)
|
||||
escoria.main.save_game(save_game)
|
||||
save_game.custom_data = escoria.game_scene.get_custom_data()
|
||||
|
||||
return save_game
|
||||
|
||||
|
||||
@@ -323,6 +325,7 @@ func save_settings():
|
||||
settings_res.speech_volume = escoria.settings.speech_volume
|
||||
settings_res.fullscreen = escoria.settings.fullscreen
|
||||
settings_res.skip_dialog = escoria.settings.skip_dialog
|
||||
settings_res.custom_settings = escoria.settings.custom_settings
|
||||
|
||||
var directory: Directory = Directory.new()
|
||||
if not directory.dir_exists(settings_folder):
|
||||
|
||||
@@ -27,3 +27,6 @@ export var globals: Dictionary = {}
|
||||
|
||||
# Escoria objects exported from ESCObjectsManager
|
||||
export var objects: Dictionary = {}
|
||||
|
||||
# Custom data
|
||||
export var custom_data: Dictionary = {}
|
||||
|
||||
@@ -41,3 +41,6 @@ export var fullscreen: bool = false
|
||||
|
||||
# True if skipping dialogs is allowed
|
||||
export var skip_dialog: bool = true
|
||||
|
||||
# Dictionary containing all user-defined settings.
|
||||
export var custom_settings: Dictionary
|
||||
|
||||
@@ -306,6 +306,8 @@ func apply_settings(p_settings: ESCSaveSettings) -> void:
|
||||
linear2db(settings.speech_volume)
|
||||
)
|
||||
TranslationServer.set_locale(settings.text_lang)
|
||||
|
||||
game_scene.apply_custom_settings(settings.custom_settings)
|
||||
|
||||
|
||||
# Input function to manage specific input keys
|
||||
|
||||
Reference in New Issue
Block a user