adds a lot holy crap i forgot to commit
This commit is contained in:
@ -6,6 +6,7 @@ extends Node2D
|
||||
|
||||
# Card information.
|
||||
var card_info: Dictionary
|
||||
var cached_image: Image
|
||||
|
||||
# Card properties.
|
||||
var tapped: bool
|
||||
@ -55,7 +56,7 @@ func _on_mouse_entered() -> void:
|
||||
|
||||
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
|
||||
$TweenController.scale(1.05)
|
||||
EventBus.emit_signal("card_on_hover", card_info)
|
||||
EventBus.emit_signal("card_on_hover", card_info, cached_image)
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
|
@ -46,15 +46,23 @@ func _load_data() -> Error:
|
||||
|
||||
|
||||
func _load_image() -> Error:
|
||||
# NOTE: Assuming we're going with using the .png cards on board.
|
||||
var cached_img = FileAccess.get_file_as_bytes("user://card_cache/" + card.card_info["id"] + "/card.png")
|
||||
|
||||
if cached_img.is_empty():
|
||||
push_error("%sCard on-board image was not found in cache" % card.error("CACHE"))
|
||||
return FAILED
|
||||
|
||||
var cache_image = Image.new()
|
||||
var image_status: Error = cache_image.load_png_from_buffer(cached_img)
|
||||
|
||||
if image_status != OK:
|
||||
push_error("%sCard on-board image failed to load correctly" % card.error("IMAGE"))
|
||||
return FAILED
|
||||
|
||||
card.cached_image = cache_image
|
||||
|
||||
var image = Image.new()
|
||||
var image_status: Error = image.load_png_from_buffer(cached_img)
|
||||
image_status = image.load_png_from_buffer(cached_img)
|
||||
|
||||
if image_status != OK:
|
||||
push_error("%sCard on-board image failed to load correctly" % card.error("IMAGE"))
|
||||
@ -69,4 +77,5 @@ func _load_image() -> Error:
|
||||
var card_sprite = card.get_node("Sprite2D")
|
||||
card_sprite.texture = image_texture
|
||||
|
||||
|
||||
return OK
|
||||
|
14
scenes/tooltip/card_image.gd
Normal file
14
scenes/tooltip/card_image.gd
Normal file
@ -0,0 +1,14 @@
|
||||
extends TextureRect
|
||||
|
||||
func _set_tip_image(_card_info: Dictionary, card_image: Image) -> void:
|
||||
card_image.resize(int(size.x / 1.75), int(size.y), Image.INTERPOLATE_LANCZOS)
|
||||
var tex = ImageTexture.new()
|
||||
tex.set_image(card_image)
|
||||
texture = tex
|
||||
|
||||
func _clear_tip_image() -> void:
|
||||
texture = null
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.connect("card_on_hover", _set_tip_image)
|
||||
EventBus.connect("card_on_unhover", _clear_tip_image)
|
1
scenes/tooltip/card_image.gd.uid
Normal file
1
scenes/tooltip/card_image.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cpvbftm0swoa6
|
12
scenes/tooltip/card_text.gd
Normal file
12
scenes/tooltip/card_text.gd
Normal file
@ -0,0 +1,12 @@
|
||||
extends RichTextLabel
|
||||
|
||||
func _set_tip_text(card_info: Dictionary, _card_image: Image) -> void:
|
||||
text = card_info["name"] + " | " + card_info["type"] + "\n"
|
||||
text += card_info["desc"]
|
||||
|
||||
func _clear_tip_text() -> void:
|
||||
text = ""
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.connect("card_on_hover", _set_tip_text)
|
||||
EventBus.connect("card_on_unhover", _clear_tip_text)
|
1
scenes/tooltip/card_text.gd.uid
Normal file
1
scenes/tooltip/card_text.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b8tioen4n1rip
|
Reference in New Issue
Block a user