ajout du déblocage/évolutions des plantes (#89) et fix divers

This commit is contained in:
2025-11-07 13:26:04 +01:00
parent 11ae967845
commit ed675ed532
54 changed files with 901 additions and 483 deletions

View File

@@ -1,27 +1,55 @@
@tool
extends TextureRect
extends SubViewportContainer
class_name CardVisualiser
signal clicked(c: CardVisualiser)
const MAX_ROT = 15
const ZOOM_SCALE = 1.0
const ZOOM_SCALE = 1.2
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 :
@export var card_width : int = 250 :
set(v):
card_width = v
if is_ready :
update()
@export var small_mode : bool = true :
set(v):
var old = small_mode
small_mode = v
if is_ready : update()
if is_ready and old != small_mode :
update()
@export var interactive_small_mode : bool = true
@export var interactive_zoom : bool = false
@export var down_arrow : bool = true :
set(v):
var old = down_arrow
down_arrow = v
if is_ready and old != down_arrow :
update()
@export var card_info : CardInfo = null :
set(v):
var old = card_info
card_info = v
if is_ready : update()
if is_ready and old != card_info:
update()
@export_tool_button("Update", "Callable") var update_action = update
var updated_on_last_frame = false
func _input(event):
if event.is_action_pressed("action") and is_mouse_over():
clicked.emit(self)
func _ready():
material = material.duplicate()
update()
@@ -32,17 +60,21 @@ func _process(_d):
if is_mouse_over():
wanted_rot = center_relative_mouse_position * MAX_ROT
small_mode = false
if interactive_small_mode: small_mode = false
if interactive_zoom: scale = scale.lerp(Vector2.ONE * ZOOM_SCALE, 0.2)
else:
wanted_rot = Vector2.ZERO
small_mode = true
if interactive_small_mode: small_mode = true
if interactive_zoom: scale = scale.lerp(Vector2.ONE, 0.2)
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
%Card.custom_minimum_size.x = card_width
%CardContainer.size.y = 0
%SubViewport.size = %CardContainer.size
size = %SubViewport.size
@@ -55,8 +87,10 @@ func is_mouse_over() -> bool:
)
func update():
if card_info:
%Card.info = card_info
%Card.small_mode = small_mode
%Card.down_arrow = down_arrow
%Card.update()
updated_on_last_frame = true