implement dynamic cloud sync
This commit is contained in:
parent
70eca755b4
commit
688c56a564
|
|
@ -1,10 +1,39 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var has_initialized
|
var is_initialized: bool = false
|
||||||
|
var steam_cloud_on: bool = false
|
||||||
|
var save_list: Dictionary[String, SaveGame]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var initialize_response: Dictionary = Steam.steamInitEx()
|
var initialize_response: Dictionary = Steam.steamInitEx()
|
||||||
if State.disconnect_steam:
|
if State.disconnect_steam:
|
||||||
Steam.steamShutdown()
|
Steam.steamShutdown()
|
||||||
|
elif initialize_response["status"] == Steam.STEAM_API_INIT_RESULT_OK:
|
||||||
|
steam_cloud_on = Steam.isCloudEnabledForAccount() && Steam.isCloudEnabledForApp()
|
||||||
|
|
||||||
|
Steam.local_file_changed.connect(_on_steam_cloud_file_changed)
|
||||||
|
Steam.inputInit()
|
||||||
|
Steam.enableDeviceCallbacks()
|
||||||
|
SteamInputManager.init()
|
||||||
|
|
||||||
|
is_initialized = true
|
||||||
else:
|
else:
|
||||||
has_initialized = initialize_response["status"] == 0
|
SteamInputManager.process_mode = Node.PROCESS_MODE_DISABLED
|
||||||
|
|
||||||
|
func _on_steam_cloud_file_changed() -> void:
|
||||||
|
if OS.has_feature("debug"):
|
||||||
|
print("Received Steam localFileChanged callback...")
|
||||||
|
|
||||||
|
var paths_changed: PackedStringArray = []
|
||||||
|
var paths_deleted: PackedStringArray = []
|
||||||
|
|
||||||
|
for i: int in Steam.getLocalFileChangeCount():
|
||||||
|
var result: Dictionary = Steam.getLocalFileChange(i)
|
||||||
|
if result["path_type"] == Steam.FILE_PATH_TYPE_ABSOLUTE:
|
||||||
|
if result["file"].ends_with("png"): pass
|
||||||
|
if result["change_type"] == Steam.LOCAL_FILE_CHANGE_FILE_UPDATED:
|
||||||
|
paths_changed.append(result["file"])
|
||||||
|
elif result["change_type"] == Steam.LOCAL_FILE_CHANGE_FILE_DELETED:
|
||||||
|
paths_deleted.append(result["file"])
|
||||||
|
|
||||||
|
Main.handle_save_update(paths_changed, paths_deleted)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue