Handle token model URL casing variants
This commit is contained in:
@@ -325,7 +325,8 @@ func add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false,
|
||||
if not def.is_empty():
|
||||
_prime_unit_sfx(def)
|
||||
var model_asset: Dictionary = find_model3d_asset(def)
|
||||
var model_url: String = _clean_optional_url(unit.get("modelUrl", ""))
|
||||
var model_url: String = _first_clean_optional_url(unit,
|
||||
["modelUrl", "ModelUrl", "modelURL", "ModelURL", "model_url"])
|
||||
var model_etag: String = ""
|
||||
if model_url.is_empty():
|
||||
model_url = _clean_optional_url(model_asset.get("cdnUrl", ""))
|
||||
@@ -1187,6 +1188,15 @@ func _clean_optional_url(value: Variant) -> String:
|
||||
return text
|
||||
|
||||
|
||||
func _first_clean_optional_url(source: Dictionary, keys: Array[String]) -> String:
|
||||
for key: String in keys:
|
||||
if source.has(key):
|
||||
var url: String = _clean_optional_url(source.get(key))
|
||||
if not url.is_empty():
|
||||
return url
|
||||
return ""
|
||||
|
||||
|
||||
## Returns the first Model3D asset dict for a card definition, or {} if none.
|
||||
func find_model3d_asset(def: Dictionary) -> Dictionary:
|
||||
for asset: Variant in def.get("assets", []):
|
||||
|
||||
Reference in New Issue
Block a user