mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-12-15 15:30:21 -08:00
Moved merge_dict() to Global
This was done to match another PR I'm working on for the world select and level select menus. Its a very basic function, but its pretty generally applicable for any custom JSON functionality and makes it easy to safely merge JSON values with variables when needed.
This commit is contained in:
parent
2733876d29
commit
e696e21f33
2 changed files with 10 additions and 10 deletions
|
|
@ -599,14 +599,6 @@ func physics_params(type: String, params_dict: Dictionary = {}, key: String = ""
|
||||||
print("NULL PARAMETER! Looking up: type='%s', key='%s'\nparams_dict='%s'" % [type, key, params_dict["Default"]])
|
print("NULL PARAMETER! Looking up: type='%s', key='%s'\nparams_dict='%s'" % [type, key, params_dict["Default"]])
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func merge_dict(target: Dictionary, source: Dictionary) -> void:
|
|
||||||
# SkyanUltra: Used to properly merge dictionaries in CharacterInfo rather than out right overwriting entries.
|
|
||||||
for key in source.keys():
|
|
||||||
if target.has(key) and target[key] is Dictionary and source[key] is Dictionary:
|
|
||||||
merge_dict(target[key], source[key])
|
|
||||||
else:
|
|
||||||
target[key] = source[key]
|
|
||||||
|
|
||||||
func apply_character_physics() -> void:
|
func apply_character_physics() -> void:
|
||||||
var apply_gameplay_changes = [Global.GameMode.BOO_RACE, Global.GameMode.MARATHON, Global.GameMode.MARATHON_PRACTICE].has(Global.current_game_mode) == false
|
var apply_gameplay_changes = [Global.GameMode.BOO_RACE, Global.GameMode.MARATHON, Global.GameMode.MARATHON_PRACTICE].has(Global.current_game_mode) == false
|
||||||
var path = "res://Assets/Sprites/Players/" + character + "/CharacterInfo.json"
|
var path = "res://Assets/Sprites/Players/" + character + "/CharacterInfo.json"
|
||||||
|
|
@ -624,12 +616,12 @@ func apply_character_physics() -> void:
|
||||||
if key in ["PHYSICS_PARAMETERS", "CLASSIC_PARAMETERS", "POWER_PARAMETERS", "ENDING_PARAMETERS"]:
|
if key in ["PHYSICS_PARAMETERS", "CLASSIC_PARAMETERS", "POWER_PARAMETERS", "ENDING_PARAMETERS"]:
|
||||||
if apply_gameplay_changes:
|
if apply_gameplay_changes:
|
||||||
if get(key) is Dictionary and json.physics[key] is Dictionary:
|
if get(key) is Dictionary and json.physics[key] is Dictionary:
|
||||||
merge_dict(get(key), json.physics[key])
|
Global.merge_dict(get(key), json.physics[key])
|
||||||
else:
|
else:
|
||||||
set(key, json.physics[key])
|
set(key, json.physics[key])
|
||||||
else:
|
else:
|
||||||
if get(key) is Dictionary and json.physics[key] is Dictionary:
|
if get(key) is Dictionary and json.physics[key] is Dictionary:
|
||||||
merge_dict(get(key), json.physics[key])
|
Global.merge_dict(get(key), json.physics[key])
|
||||||
else:
|
else:
|
||||||
set(key, json.physics[key])
|
set(key, json.physics[key])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -507,3 +507,11 @@ func get_base_asset_version() -> int:
|
||||||
|
|
||||||
func get_version_num_int(ver_num := "0.0.0") -> int:
|
func get_version_num_int(ver_num := "0.0.0") -> int:
|
||||||
return int(ver_num.replace(".", ""))
|
return int(ver_num.replace(".", ""))
|
||||||
|
|
||||||
|
func merge_dict(target: Dictionary, source: Dictionary) -> void:
|
||||||
|
# SkyanUltra: Used to properly merge dictionaries in CharacterInfo rather than out right overwriting entries.
|
||||||
|
for key in source.keys():
|
||||||
|
if target.has(key) and target[key] is Dictionary and source[key] is Dictionary:
|
||||||
|
merge_dict(target[key], source[key])
|
||||||
|
else:
|
||||||
|
target[key] = source[key]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue