diff --git a/src/logic-scenes/board/card.gd b/src/logic-scenes/board/card.gd index bc2d486..46ab6ee 100644 --- a/src/logic-scenes/board/card.gd +++ b/src/logic-scenes/board/card.gd @@ -50,6 +50,8 @@ var scale_tween wiggle_intensity = 0 @export var voice_line: AudioStream = null +@export var is_dragable: bool = false +var is_dragged: bool = false func _ready(): @@ -93,3 +95,24 @@ func _on_focus_entered(): func _on_focus_exited(): print(self, "is not focused") + +func _on_mouse_entered(): + if not Input.is_action_pressed("mouse_left"): + highlighted = true + if "handle_hover" in owner: + owner.handle_hover(self) + +func _on_mouse_exited(): + highlighted = false + +func _on_input_event(viewport, event, shape_idx): + if event is InputEventMouseMotion and is_dragged: + position += event.relative + + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if is_dragable: + is_dragged = event.pressed + if "handle_mouse_button" in owner: + owner.handle_mouse_button(self, event) + diff --git a/src/logic-scenes/board/card.tscn b/src/logic-scenes/board/card.tscn index baa871d..89f6a60 100644 --- a/src/logic-scenes/board/card.tscn +++ b/src/logic-scenes/board/card.tscn @@ -146,19 +146,18 @@ func _process(_delta): " [node name="card" type="Area2D"] -rotation = -0.0265383 +rotation = -0.0714123 script = ExtResource("1_emip0") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-0.0713516, 0.997451) rotation = 1.5708 -scale = Vector2(1, 1) shape = SubResource("CapsuleShape2D_foovg") [node name="BackgroundSprite" type="AnimatedSprite2D" parent="."] clip_children = 2 scale = Vector2(0.6, 0.6) sprite_frames = SubResource("SpriteFrames_ckivt") -frame = 1 script = SubResource("GDScript_8bs16") [node name="GPUParticles2D" type="GPUParticles2D" parent="BackgroundSprite"] @@ -202,3 +201,7 @@ offset_left = 100.0 offset_top = 148.0 offset_right = 140.0 offset_bottom = 188.0 + +[connection signal="input_event" from="." to="." method="_on_input_event"] +[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"] diff --git a/src/logic-scenes/board/physics-board.tscn b/src/logic-scenes/board/physics-board.tscn index ea0e74a..4b1b0c5 100644 --- a/src/logic-scenes/board/physics-board.tscn +++ b/src/logic-scenes/board/physics-board.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=9 format=3 uid="uid://bnskiyx1sksww"] +[gd_scene load_steps=10 format=3 uid="uid://bnskiyx1sksww"] [ext_resource type="Texture2D" uid="uid://bi3xqdknw5tpe" path="res://logic-scenes/board/board-texture/Cork002_2K_Color.png" id="1_8brxc"] [ext_resource type="Shader" path="res://logic-scenes/board/physics-board.gdshader" id="1_ggnth"] [ext_resource type="Script" path="res://logic-scenes/board/card-board.gd" id="3_8v4c4"] [ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="3_mg053"] [ext_resource type="PackedScene" uid="uid://bvowj4l8dtceu" path="res://dev-util/board of devs.tscn" id="4_sskx2"] +[ext_resource type="PackedScene" uid="uid://vkcdj8c3ytbq" path="res://logic-scenes/board/post-it.tscn" id="5_048k0"] [ext_resource type="Script" path="res://logic-scenes/board/bouncy-card.gd" id="6_gcxd7"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_ttqei"] @@ -15,7 +16,7 @@ shader_parameter/tex = ExtResource("1_8brxc") [sub_resource type="CircleShape2D" id="CircleShape2D_x8rl2"] radius = 154.052 -[node name="Panel" type="PanelContainer"] +[node name="board" type="PanelContainer"] material = SubResource("ShaderMaterial_ttqei") clip_contents = true anchors_preset = 15 @@ -25,46 +26,79 @@ grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 6 size_flags_vertical = 6 +mouse_filter = 1 script = ExtResource("3_8v4c4") [node name="HBoxContainer" type="HBoxContainer" parent="."] layout_mode = 2 -[node name="Panel" type="Panel" parent="HBoxContainer"] +[node name="dropzone" type="Panel" parent="HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 +mouse_filter = 1 -[node name="Control" type="Control" parent="HBoxContainer/Panel"] -anchors_preset = 0 -offset_left = 305.0 -offset_top = 463.0 -offset_right = 305.0 -offset_bottom = 463.0 +[node name="card3" parent="HBoxContainer/dropzone" instance=ExtResource("3_mg053")] +z_as_relative = false +position = Vector2(371, 290) +rotation = 0.00712087 +collision_layer = 2147483649 -[node name="card3" parent="HBoxContainer/Panel/Control" instance=ExtResource("3_mg053")] -offset_left = 0.0 -offset_top = 0.0 -offset_right = 0.0 -offset_bottom = 0.0 +[node name="card" parent="HBoxContainer/dropzone" instance=ExtResource("3_mg053")] +position = Vector2(640, 659) +rotation = 0.0714344 +scale = Vector2(1, 1) +is_dragable = true -[node name="VBoxContainer3" type="VBoxContainer" parent="HBoxContainer"] +[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"] layout_mode = 2 -size_flags_horizontal = 8 - -[node name="CenterContainer" type="ScrollContainer" parent="HBoxContainer/VBoxContainer3"] -layout_mode = 2 -size_flags_vertical = 3 horizontal_scroll_mode = 0 -[node name="post-ancor" type="Panel" parent="HBoxContainer/VBoxContainer3/CenterContainer"] -custom_minimum_size = Vector2(320, 110) +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"] layout_mode = 2 +[node name="Panel" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"] +custom_minimum_size = Vector2(400, 120) +layout_mode = 2 +mouse_filter = 1 + +[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel" instance=ExtResource("5_048k0")] +z_index = 1 +position = Vector2(105, 57) +is_dragable = true + +[node name="Panel2" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"] +custom_minimum_size = Vector2(400, 120) +layout_mode = 2 +mouse_filter = 1 + +[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel2" instance=ExtResource("5_048k0")] +position = Vector2(105, 57) +is_dragable = true + +[node name="Panel3" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"] +custom_minimum_size = Vector2(400, 120) +layout_mode = 2 +mouse_filter = 1 + +[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel3" instance=ExtResource("5_048k0")] +position = Vector2(105, 57) +is_dragable = true + +[node name="Panel4" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"] +custom_minimum_size = Vector2(400, 120) +layout_mode = 2 +mouse_filter = 1 + +[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel4" instance=ExtResource("5_048k0")] +position = Vector2(105, 57) +is_dragable = true + [node name="board of devs" parent="." instance=ExtResource("4_sskx2")] visible = false layout_mode = 2 [node name="Node2D" type="Node2D" parent="."] +visible = false [node name="RigidBody2D" type="Area2D" parent="Node2D"] position = Vector2(686, 379) @@ -77,10 +111,8 @@ shape = SubResource("CircleShape2D_x8rl2") position = Vector2(-151, -107) [node name="card2" parent="Node2D/RigidBody2D/ancor" instance=ExtResource("3_mg053")] -offset_left = 0.0 -offset_top = 0.0 -offset_right = 0.0 -offset_bottom = 0.0 +rotation = -0.0180459 +collision_layer = 2 [node name="RigidBody2D2" type="Area2D" parent="Node2D"] position = Vector2(742, 323) @@ -93,10 +125,8 @@ shape = SubResource("CircleShape2D_x8rl2") position = Vector2(-151, -107) [node name="card2" parent="Node2D/RigidBody2D2/ancor" instance=ExtResource("3_mg053")] -offset_left = 0.0 -offset_top = 0.0 -offset_right = 0.0 -offset_bottom = 0.0 +rotation = 0.0612526 +collision_layer = 2 [node name="RigidBody2D3" type="Area2D" parent="Node2D"] position = Vector2(694, 353) @@ -109,7 +139,5 @@ shape = SubResource("CircleShape2D_x8rl2") position = Vector2(-151, -107) [node name="card2" parent="Node2D/RigidBody2D3/ancor" instance=ExtResource("3_mg053")] -offset_left = 0.0 -offset_top = 0.0 -offset_right = 0.0 -offset_bottom = 0.0 +rotation = 0.0528008 +collision_layer = 2 diff --git a/src/logic-scenes/board/post-it.gd b/src/logic-scenes/board/post-it.gd index 409009a..19ba4d0 100644 --- a/src/logic-scenes/board/post-it.gd +++ b/src/logic-scenes/board/post-it.gd @@ -41,6 +41,8 @@ var modulate_tween modulate = Color(1, 1, 1) @export var voice_line: AudioStream = null +@export var is_dragable: bool = false +var is_dragged = false func _ready() -> void: $Content/Label.text = self.text @@ -60,3 +62,23 @@ func _on_focus_entered(): func _on_focus_exited(): print(self, "is not focused") + +func _on_mouse_entered(): + if not Input.is_action_pressed("mouse_left"): + highlighted = true + if "handle_hover" in owner: + owner.handle_hover(self) + +func _on_mouse_exited(): + highlighted = false + +func _on_input_event(viewport, event, shape_idx): + if event is InputEventMouseMotion and is_dragged: + position += event.relative + + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if is_dragable: + is_dragged = event.pressed + if "handle_mouse_button" in owner: + owner.handle_mouse_button(self, event) diff --git a/src/logic-scenes/board/post-it.tscn b/src/logic-scenes/board/post-it.tscn index cc1bb8f..15f49b0 100644 --- a/src/logic-scenes/board/post-it.tscn +++ b/src/logic-scenes/board/post-it.tscn @@ -103,6 +103,7 @@ animations = [{ [node name="post-it" type="Area2D"] script = ExtResource("1_yvh5n") highlight_color = Color(1.2, 1.2, 1.2, 1) +is_dragable = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(99.5, 0) @@ -133,3 +134,7 @@ theme = ExtResource("3_hu2as") theme_type_variation = &"card_text" vertical_alignment = 1 autowrap_mode = 3 + +[connection signal="input_event" from="." to="." method="_on_input_event"] +[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]