Fixed set_progress and get_progress

Added a property check which no longer prevents null and zero values from being updated.
This commit is contained in:
Matthias Stöckli 2017-10-21 15:55:24 +02:00
parent 980a2219e1
commit cd56325a52
2 changed files with 12 additions and 22 deletions

View File

@ -28,16 +28,16 @@ func load_item_value(item, property):
func get_progress(item_class, id, property):
if items[item_class].has(id) and items[item_class][id].has(property):
var item_exists = items[item_class].has(id)
if item_exists and property in items[item_class][id]:
return items[item_class][id][property]
func set_progress(item_class, id, property, value):
var item = item_manager.get_item(item_class, id)
var has_value = item.get(property)
if item and has_value:
var item = item_manager.get_item(item_class, id)
if item and property in item:
item.set(property, value)
if has_user_signal("@any_value_changed"):
if has_user_signal("@any_value_changed "):
emit_signal("@any_value_changed", item, property, value)
var signal_name = ""
@ -130,9 +130,4 @@ func stop_observing_changes(observer):
func set_item_progress(item, property, value):
set_progress(item._class, item._id, property, value)
func get_progress_by_item(item):
set_progress(item._class, item._id, property, value)

View File

@ -28,16 +28,16 @@ func load_item_value(item, property):
func get_progress(item_class, id, property):
if items[item_class].has(id) and items[item_class][id].has(property):
var item_exists = items[item_class].has(id)
if item_exists and property in items[item_class][id]:
return items[item_class][id][property]
func set_progress(item_class, id, property, value):
var item = item_manager.get_item(item_class, id)
var has_value = item.get(property)
if item and has_value:
var item = item_manager.get_item(item_class, id)
if item and property in item:
item.set(property, value)
if has_user_signal("@any_value_changed"):
if has_user_signal("@any_value_changed "):
emit_signal("@any_value_changed", item, property, value)
var signal_name = ""
@ -130,9 +130,4 @@ func stop_observing_changes(observer):
func set_item_progress(item, property, value):
set_progress(item._class, item._id, property, value)
func get_progress_by_item(item):
set_progress(item._class, item._id, property, value)