feat: card zoom

This commit is contained in:
Kenshia 2025-01-26 11:49:25 +07:00
parent cd9f7c7679
commit 83df3047f7
3 changed files with 33 additions and 18 deletions

View file

@ -3,6 +3,7 @@ class_name CardBase
signal left_clicked
signal right_clicked
signal un_right_clicked
signal hovering(delta: float)
@export var card_name_label: Label
@ -25,20 +26,17 @@ func _update(card: SupportCard):
func _process(delta):
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if rect.has_point(mouse_position):
if rect.has_point(mouse_position) and get_window().has_focus():
hovering.emit(delta)
func _input(event):
if event is InputEventMouseButton:
if !event.is_pressed():
return
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if not rect.has_point(mouse_position):
return
if event.button_index == MOUSE_BUTTON_LEFT:
if rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() and get_window().has_focus():
left_clicked.emit()
elif event.button_index == MOUSE_BUTTON_RIGHT:
elif rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_RIGHT and event.is_pressed() and get_window().has_focus():
right_clicked.emit()
elif event.button_index == MOUSE_BUTTON_RIGHT and !event.is_pressed():
un_right_clicked.emit()

View file

@ -3,6 +3,7 @@ class_name MonsterCardUI
signal left_clicked
signal right_clicked
signal un_right_clicked
signal hovering(delta: float)
@export var name_label : Label
@ -37,20 +38,17 @@ func show_monster(monster: MatchMonster):
func _process(delta):
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if rect.has_point(mouse_position):
if rect.has_point(mouse_position) and get_window().has_focus():
hovering.emit(delta)
func _input(event):
if event is InputEventMouseButton:
if !event.is_pressed():
return
var mouse_position = get_global_mouse_position()
var rect = get_global_rect()
if not rect.has_point(mouse_position):
return
if event.button_index == MOUSE_BUTTON_LEFT:
if rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() and get_window().has_focus():
left_clicked.emit()
elif event.button_index == MOUSE_BUTTON_RIGHT:
elif rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_RIGHT and event.is_pressed() and get_window().has_focus():
right_clicked.emit()
elif event.button_index == MOUSE_BUTTON_RIGHT and !event.is_pressed():
un_right_clicked.emit()