seeding-planets/gui/game/card/scripts/card_visualiser.gd
Zacharie Guet ed7a8bcb6e gros dev pre proto
* Changement de l'UI, ajouts de l'inspecteur par carte et changement de police
* Ajout d'un semblant d'exploration
* Ajout de la sauvegarde des entités
* Restructuration mineure de l'arborescence
* Fix divers et réécriture des textes
2025-10-31 13:52:45 +01:00

63 lines
1.3 KiB
GDScript

@tool
extends TextureRect
const MAX_ROT = 15
const ZOOM_SCALE = 1.0
var wanted_rot : Vector2 = Vector2.ZERO
var real_rot : Vector2 = Vector2.ZERO
var wanted_scale : Vector2 = Vector2.ONE
var is_ready = false
@export var small_mode : bool = false :
set(v):
small_mode = v
if is_ready : update()
@export var card_info : CardInfo = null :
set(v):
card_info = v
if is_ready : update()
@export_tool_button("Update", "Callable") var update_action = update
func _ready():
material = material.duplicate()
update()
is_ready = true
func _process(_d):
var center_relative_mouse_position = (get_local_mouse_position() - size/2) / size
if is_mouse_over():
wanted_rot = center_relative_mouse_position * MAX_ROT
small_mode = false
else:
wanted_rot = Vector2.ZERO
small_mode = true
real_rot = real_rot.lerp(wanted_rot, 0.1)
material.set_shader_parameter("y_rot", - real_rot.x)
material.set_shader_parameter("x_rot", real_rot.y)
%SubViewport.size.y = %CardContainer.size.y
size = %SubViewport.size
func is_mouse_over() -> bool:
var center_relative_mouse_position = (get_local_mouse_position() - size/2) / size
return (
abs(center_relative_mouse_position.x) < 0.5
and abs(center_relative_mouse_position.y) < 0.5
)
func update():
if card_info:
%Card.info = card_info
%Card.small_mode = small_mode
%Card.update()