Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with images: after saving, they remain stuck until the scene changes! #2446

Open
maron5466 opened this issue Oct 18, 2024 · 0 comments
Labels
Needs testing More feedback/testing would be good

Comments

@maron5466
Copy link

The problem

Describe the bug
I used the saving system suggested for Dialogic 2, but after I load any save, the images present at the save moment remain stuck until the scene changes. Everything else work fine.

To Reproduce
I save wih this:
func save_global_state(slot_name: String):
if slot_name.strip_edges() == "":
print("Nome del file di salvataggio non valido!")
return

global.caricamento_attivo = true

# Salva i dati globali
var lista_quest_dict = []
for oggetto_quest in lista_quest:
	lista_quest_dict.append(quest_to_dict(oggetto_quest))
var global_data = {} ###all datas are here 

Save global data using Dialogic's global save method

for key in global_data.keys():
	Dialogic.Save.set_global_info(key, global_data[key])
var nome = "user://%s.save" % slot_name
var file = FileAccess.open(nome, FileAccess.WRITE)
var json_string = JSON.stringify(global_data)
file.store_line(json_string)
file.close()

var dialogic_extra_info = {
	"slot_name": slot_name,
	"timestamp": Time.get_datetime_string_from_system()
}
Dialogic.Save.save(slot_name, false, Dialogic.Save.ThumbnailMode.STORE_ONLY, dialogic_extra_info)
var save_file_path = "user://%d.save" % slot_name
var save_file = FileAccess.open(save_file_path, FileAccess.WRITE)

# Save the slot name
save_file.store_line(slot_name)
#

var save_nodes = get_tree().get_nodes_in_group("Persist")
for node in save_nodes:
	if node.scene_file_path.is_empty():
		print("Persistent node '%s' is not an instanced scene, skipped" % node.name)
		continue

	if !node.has_method("save"):
		print("Persistent node '%s' is missing a save() function, skipped" % node.name)
		continue

	var node_data = node.call("save")
	node_data["slot_name"] = slot_name  # Save the slot name in the data

	var node_json_string = JSON.stringify(node_data)
	print("Saving node data for '%s': %s" % [node.name, json_string])  # Print node data being saved
	save_file.store_line(node_json_string)

save_file.close()
print("Game saved to slot %d!" % slot_name)
global.caricamento_attivo = false

For loading:
func load_global_state(slot_name: String):
if slot_name.strip_edges() == "":
print("Nome del file di caricamento non valido!")
return

# Percorso del file di salvataggio
#var file_path = "user://saves" + slot_name + ".save"
var file_path = "user://" + slot_name + ".save"
if not FileAccess.file_exists(file_path):
	print("Save file non trovato per slot %s" % slot_name)
	return

# Apri il file per lettura
var file = FileAccess.open(file_path, FileAccess.READ)
var json_string = file.get_line()
var json = JSON.new()
var parse_result = json.parse(json_string)

if parse_result != OK:
	print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line())
	return

var global_data = json.get_data()

# Carica la lista di quest
global.lista_quest.clear()
for quest_dict in global_data.get("lista_quest", []):
	var oggetto_quest = dict_to_quest(quest_dict)
	global.lista_quest.append(oggetto_quest)  

###many loading files that are repetitive like global.delo_5_days = global_data["delo_5_days"]

	# Load global data using Dialogic's global load method
for key in global_data.keys():
	if Dialogic.Save.get_global_info(key, global_data[key]):
		global_data[key] = Dialogic.Save.get_global_info(key, global_data[key])
	else:
		print("Global data not found for key: ", key)
		
if Dialogic.Save.has_slot(slot_name):
	Dialogic.Save.load(slot_name)

file.close()

Expected behavior
I expected the game to work normally, but the image remained stuck there.

System (please complete the following information):

  • OS: Mac
  • Godot Version: 4.2.1
  • Dialogic Version: 2.0 Alpha 14
@Jowan-Spooner Jowan-Spooner added the Needs testing More feedback/testing would be good label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs testing More feedback/testing would be good
Projects
None yet
Development

No branches or pull requests

2 participants