back_face="" for cards no longer throws an error.

If the back_face property is blank, then a black 1x1 texture is used
in it's place.

This commit fixes #118.
This commit is contained in:
drwhut 2022-11-30 17:29:49 +00:00
parent 44a08e3b4e
commit 36517889f1
5 changed files with 61 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/BlackTexture.bmp-197d845b0d42dd143a03649ed7fda370.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/BlackTexture.bmp"
dest_files=[ "res://.import/BlackTexture.bmp-197d845b0d42dd143a03649ed7fda370.stex" ]
[params]
compress/mode=3
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=2
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=0
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -1024,6 +1024,8 @@ func _import_asset(from: String, pack: String, type: String, config: ConfigFile,
print("Loaded back face: %s" % back_path)
else:
push_error("Failed to import '%s' (error %d)!" % [back_path, back_err])
else:
entry["texture_path_1"] = ""
elif type.begins_with("containers"):
entry["shakable"] = _get_file_config_value(config, from.get_file(), "shakable", false)
@ -1622,7 +1624,7 @@ func _is_valid_entry(pack: String, type: String, entry: Dictionary) -> bool:
push_error("'texture_path_1' in entry is not a string!")
return false
if not _is_valid_path(value, VALID_TEXTURE_EXTENSIONS):
if not (value.empty() or _is_valid_path(value, VALID_TEXTURE_EXTENSIONS)):
push_error("'texture_path_1' in entry is not a valid path!")
return false
"url":

View File

@ -124,9 +124,16 @@ func _set_sandwich_display() -> void:
var front_key = "texture_path"
if front_flip:
front_key += "_1"
var front_path: String = front_entry[front_key]
var front_texture: Texture
if not front_path.empty():
front_texture = ResourceManager.load_res(front_path)
else:
front_texture = preload("res://Images/BlackTexture.bmp")
var front_material = SpatialMaterial.new()
front_material.albedo_color = front_entry["color"]
front_material.albedo_texture = ResourceManager.load_res(front_entry[front_key])
front_material.albedo_texture = front_texture
sandwich.set_surface_material(0, front_material)
var back_meta = _pieces[0]
@ -136,7 +143,14 @@ func _set_sandwich_display() -> void:
var back_key = "texture_path"
if not back_flip:
back_key += "_1"
var back_path: String = back_entry[back_key]
var back_texture: Texture
if not back_path.empty():
back_texture = ResourceManager.load_res(back_path)
else:
back_texture = preload("res://Images/BlackTexture.bmp")
var back_material = SpatialMaterial.new()
back_material.albedo_color = back_entry["color"]
back_material.albedo_texture = ResourceManager.load_res(back_entry[back_key])
back_material.albedo_texture = back_texture
sandwich.set_surface_material(1, back_material)

View File

@ -116,8 +116,13 @@ func build_piece(piece_entry: Dictionary, extra_nodes: bool = true) -> Piece:
# Check if the entry has textures for more than one surface.
var surface = 1
while piece_entry.has("texture_path_" + str(surface)):
texture = ResourceManager.load_res(piece_entry["texture_path_" + str(surface)])
piece.apply_texture(texture, surface)
var texture_path: String = piece_entry["texture_path_" + str(surface)]
var optional_texture: Texture
if not texture_path.empty():
optional_texture = ResourceManager.load_res(texture_path)
else:
optional_texture = preload("res://Images/BlackTexture.bmp")
piece.apply_texture(optional_texture, surface)
surface += 1
if piece.is_albedo_color_exposed():