31 lines
834 B
GDScript3
31 lines
834 B
GDScript3
|
extends Control
|
||
|
|
||
|
var cardID := "" setget set_cardid
|
||
|
var ready = false
|
||
|
|
||
|
func set_cardid(val: String):
|
||
|
cardID = val
|
||
|
if cardID != "":
|
||
|
Resources.get_card(val, self, "_card_fetched")
|
||
|
|
||
|
# warning-ignore:unused_argument
|
||
|
func _card_fetched(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray):
|
||
|
assert(result == HTTPRequest.RESULT_SUCCESS)
|
||
|
var img = Image.new()
|
||
|
var err = img.load_webp_from_buffer(body)
|
||
|
assert(err == OK)
|
||
|
if img.get_width() > img.get_height():
|
||
|
rect_min_size = Vector2(480,344)
|
||
|
rect_size = Vector2(480,344)
|
||
|
else:
|
||
|
rect_min_size = Vector2(344,480)
|
||
|
rect_size = Vector2(344,480)
|
||
|
var texture := ImageTexture.new()
|
||
|
texture.create_from_image(img)
|
||
|
$TextureRect.texture = texture
|
||
|
|
||
|
func fadein():
|
||
|
$AnimationPlayer.play("zoom-fadein")
|
||
|
|
||
|
func fadeout():
|
||
|
$AnimationPlayer.play("zoom-fadeout")
|