played card stack can now be expanded upon hovering to see which cards were played
This commit is contained in:
@@ -5,6 +5,16 @@ var _card_height: float = 0.02
|
||||
|
||||
@export var playing_card_scene: PackedScene
|
||||
|
||||
## Surface for allowing peeking at the played cards by hovering the mouse.
|
||||
@export var peek_surface: Area3D
|
||||
|
||||
var _is_expanded: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
if peek_surface:
|
||||
peek_surface.mouse_entered.connect(_peek_mouse_entered)
|
||||
peek_surface.mouse_exited.connect(_peek_mouse_exited)
|
||||
|
||||
func add_card(card: PlayingCard) -> void:
|
||||
var height = self.get_child_count() * _card_height
|
||||
self.add_child(card)
|
||||
@@ -19,3 +29,30 @@ func add_card_by_id(card_id: int) -> void:
|
||||
func purge_cards() -> void:
|
||||
while get_child_count() > 0:
|
||||
remove_child(get_children()[get_child_count() - 1])
|
||||
|
||||
func _peek_mouse_entered() -> void:
|
||||
if get_child_count() > 1:
|
||||
var index = 0
|
||||
var child_count = get_child_count()
|
||||
for child: Node3D in get_children():
|
||||
create_tween().set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT).tween_property(
|
||||
child,
|
||||
"position",
|
||||
Vector3(0.2, index * -0.42 - (((child_count - 1) * -0.42) / 2.0), _card_height * index),
|
||||
0.3,
|
||||
)
|
||||
index += 1
|
||||
_is_expanded = true
|
||||
|
||||
func _peek_mouse_exited() -> void:
|
||||
if _is_expanded:
|
||||
var index = 0
|
||||
for child: Node3D in get_children():
|
||||
create_tween().set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT).tween_property(
|
||||
child,
|
||||
"position",
|
||||
Vector3(0.0, 0.0, _card_height * index),
|
||||
0.3,
|
||||
)
|
||||
index += 1
|
||||
_is_expanded = false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://gqrdpjslr4np"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://gqrdpjslr4np"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://p5gvnyhjqe6o" path="res://components/web_client.gd" id="1_feb5d"]
|
||||
[ext_resource type="Script" uid="uid://c0cqkatyo4uj1" path="res://components/client_interface.gd" id="2_e2o6t"]
|
||||
@@ -18,6 +18,9 @@ ambient_light_source = 2
|
||||
ambient_light_color = Color(1, 1, 1, 1)
|
||||
ambient_light_energy = 0.15
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_iotsf"]
|
||||
size = Vector3(0.627106, 0.998047, 0.204102)
|
||||
|
||||
[node name="Game" type="Node"]
|
||||
|
||||
[node name="WebClient" type="Node" parent="." node_paths=PackedStringArray("chat_panel")]
|
||||
@@ -144,6 +147,7 @@ offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="ConnectionOverlay" type="Control" parent="Interface" node_paths=PackedStringArray("status_label")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -364,10 +368,18 @@ transform = Transform3D(-0.5, 0.836516, 0.224144, 0, 0.258819, -0.965925, -0.866
|
||||
[node name="Table" parent="EnvironmentManager" instance=ExtResource("7_eow3j")]
|
||||
transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0, 0, 0.704226)
|
||||
|
||||
[node name="CardStack" type="Marker3D" parent="EnvironmentManager"]
|
||||
[node name="PeekSurface" type="Area3D" parent="EnvironmentManager"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -0.999999, -4.37114e-08, 0.18, 0.279306, 0.973)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnvironmentManager/PeekSurface"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 1.54543e-12, 1, 0.14949, 0, -0.0610352)
|
||||
shape = SubResource("BoxShape3D_iotsf")
|
||||
|
||||
[node name="CardStack" type="Marker3D" parent="EnvironmentManager" node_paths=PackedStringArray("peek_surface")]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -0.999999, -4.37114e-08, 0.18, 0.115, 0.973)
|
||||
script = ExtResource("8_j5wjh")
|
||||
playing_card_scene = ExtResource("6_eow3j")
|
||||
peek_surface = NodePath("../PeekSurface")
|
||||
|
||||
[node name="TrumpStack" type="Marker3D" parent="EnvironmentManager"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -0.999999, -4.37114e-08, -0.18, 0.115, 0.973)
|
||||
|
||||
Reference in New Issue
Block a user