Add icon to types
This commit is contained in:
parent
d00dc5bba2
commit
df7ca58c5e
|
|
@ -3,6 +3,7 @@
|
|||
class_name TypeData
|
||||
extends Resource
|
||||
|
||||
@export var icon : Texture2D # illustration assignée à la main dans l'inspecteur, jamais touchée par l'import
|
||||
@export var id : int
|
||||
@export var api_name : String
|
||||
@export var names : Dictionary = {}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,13 @@ func _import_type(entry : Dictionary) -> void:
|
|||
message.emit("[color=red]Échec : %s[/color]" % entry["name"])
|
||||
return
|
||||
|
||||
var t := TypeData.new()
|
||||
# recharge la ressource existante pour préserver l'icône assignée à la main
|
||||
var t : TypeData
|
||||
if FileAccess.file_exists(path):
|
||||
t = ResourceLoader.load(path, "", ResourceLoader.CACHE_MODE_REPLACE) as TypeData
|
||||
if t == null:
|
||||
t = TypeData.new()
|
||||
|
||||
t.id = j["id"]
|
||||
t.api_name = j["name"]
|
||||
t.names = PokeApiText.names(j["names"], _languages)
|
||||
|
|
@ -53,6 +59,7 @@ func _import_type(entry : Dictionary) -> void:
|
|||
t.half_damage_from = _names_of(rel["half_damage_from"])
|
||||
t.no_damage_to = _names_of(rel["no_damage_to"])
|
||||
t.no_damage_from = _names_of(rel["no_damage_from"])
|
||||
# t.icon n'est jamais touché ici
|
||||
ResourceSaver.save(t, path)
|
||||
|
||||
func _names_of(entries : Array) -> PackedStringArray:
|
||||
|
|
|
|||
Loading…
Reference in a new issue