diff --git a/Main.tscn b/Main.tscn index ac76cad..ac8bc8a 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,8 +1,7 @@ [gd_scene format=3 uid="uid://b2rl7r8oav3hy"] [ext_resource type="PackedScene" uid="uid://dciugg77wsy6p" path="res://Meeting.tscn" id="1_glv2v"] -[ext_resource type="Script" uid="uid://dldaxqajhnnva" path="res://TimeSlot.cs" id="2_r0du0"] -[ext_resource type="PackedScene" uid="uid://do8ll0kylvrcn" path="res://MeetingControl.tscn" id="2_uu6xs"] +[ext_resource type="PackedScene" uid="uid://nnr6u0igggve" path="res://TimeSlot.tscn" id="1_uu6xs"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_sko1m"] size = Vector2(575, 20) @@ -12,46 +11,49 @@ size = Vector2(21.5, 1920) [node name="Main" type="Node2D" unique_id=287617203] -[node name="MeetingControl" parent="." unique_id=11410047 instance=ExtResource("2_uu6xs")] -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = 631.0 -offset_top = 18.0 -offset_right = 960.0 -offset_bottom = 98.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_default_cursor_shape = 2 -metadata/_edit_use_anchors_ = true - [node name="Control" type="Control" parent="." unique_id=1593899] layout_mode = 3 anchors_preset = 0 -offset_left = 114.0 -offset_top = 34.0 -offset_right = 514.0 -offset_bottom = 603.0 +offset_left = 125.0 +offset_top = 43.0 +offset_right = 455.0 +offset_bottom = 602.0 +mouse_filter = 2 [node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1636973054] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -1.0 -offset_right = -1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 [node name="VBoxContainer" type="VBoxContainer" parent="Control/PanelContainer" unique_id=1658498861] layout_mode = 2 +mouse_filter = 2 +alignment = 1 -[node name="TimeSlot" type="PanelContainer" parent="Control/PanelContainer/VBoxContainer" unique_id=1554329623] -custom_minimum_size = Vector2(0, 74) +[node name="TimeSlot" parent="Control/PanelContainer/VBoxContainer" unique_id=979842204 instance=ExtResource("1_uu6xs")] +layout_mode = 2 + +[node name="TimeSlot2" parent="Control/PanelContainer/VBoxContainer" unique_id=1532657435 instance=ExtResource("1_uu6xs")] +layout_mode = 2 + +[node name="TimeSlot3" parent="Control/PanelContainer/VBoxContainer" unique_id=1504478834 instance=ExtResource("1_uu6xs")] +layout_mode = 2 + +[node name="TimeSlot4" parent="Control/PanelContainer/VBoxContainer" unique_id=1891572413 instance=ExtResource("1_uu6xs")] +layout_mode = 2 + +[node name="TimeSlot5" parent="Control/PanelContainer/VBoxContainer" unique_id=464659559 instance=ExtResource("1_uu6xs")] +layout_mode = 2 + +[node name="TimeSlot6" parent="Control/PanelContainer/VBoxContainer" unique_id=1773919778 instance=ExtResource("1_uu6xs")] +layout_mode = 2 + +[node name="TimeSlot7" parent="Control/PanelContainer/VBoxContainer" unique_id=1476334804 instance=ExtResource("1_uu6xs")] layout_mode = 2 -script = ExtResource("2_r0du0") [node name="Box" type="StaticBody2D" parent="." unique_id=56956355] diff --git a/Meeting.cs b/Meeting.cs index 3d5ea5c..2c23859 100644 --- a/Meeting.cs +++ b/Meeting.cs @@ -37,12 +37,6 @@ public partial class Meeting : RigidBody2D } } } - - if (_isDragging && @event is InputEventMouseButton { Pressed: false }) - { - GD.Print("Let me free"); - StopDragging(); - } } public override void _PhysicsProcess(double delta) @@ -65,15 +59,18 @@ public partial class Meeting : RigidBody2D private void StartDragging() { - Freeze = true; - _isDragging = true; - CollisionLayer = 0; - } + LinearVelocity = Vector2.Zero; + AngularVelocity = 0; + RotationDegrees = 0; - private void StopDragging() - { - Freeze = false; - _isDragging = false; - CollisionLayer = 1; + var meetingControl = Instantiator.Instantiate(); + meetingControl.Meeting = this; + + GetParent().AddChild(meetingControl); + meetingControl.StartDrag(); + + meetingControl.Position = new Vector2(-5000, -5000); + + GetParent().RemoveChild(this); } } diff --git a/Meeting.tscn b/Meeting.tscn index 0ec959c..4cde238 100644 --- a/Meeting.tscn +++ b/Meeting.tscn @@ -2,12 +2,13 @@ [ext_resource type="Script" uid="uid://cit20jyhj41rs" path="res://Meeting.cs" id="1_1rolt"] [ext_resource type="Texture2D" uid="uid://dyxftkkuf7h7w" path="res://icon.svg" id="1_2t4nr"] +[ext_resource type="PackedScene" uid="uid://b2cpk0ef3rw87" path="res://MeetingControlGfx.tscn" id="2_h68fa"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_glv2v"] bounce = 0.1 [sub_resource type="RectangleShape2D" id="RectangleShape2D_boq60"] -size = Vector2(294, 72) +size = Vector2(329, 80) [node name="Meeting" type="RigidBody2D" unique_id=796440984] input_pickable = true @@ -16,9 +17,26 @@ freeze_mode = 1 continuous_cd = 2 script = ExtResource("1_1rolt") -[node name="Icon" type="Sprite2D" parent="." unique_id=1878852055] -scale = Vector2(2.3203125, 0.6015625) -texture = ExtResource("1_2t4nr") - [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=235269066] +position = Vector2(0.5, 0) shape = SubResource("RectangleShape2D_boq60") + +[node name="MeetingControlGFX" parent="." unique_id=1923695250 instance=ExtResource("2_h68fa")] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -164.5 +offset_top = -40.0 +offset_right = 164.5 +offset_bottom = 40.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="Icon" type="Sprite2D" parent="." unique_id=816382870] +self_modulate = Color(0.649173, 0, 0.25909996, 1) +position = Vector2(153, -29.000004) +scale = Vector2(0.1171875, 0.1171875) +texture = ExtResource("1_2t4nr") diff --git a/MeetingControl.cs b/MeetingControl.cs index 64bc862..e88c6f8 100644 --- a/MeetingControl.cs +++ b/MeetingControl.cs @@ -1,15 +1,65 @@ using Godot; -public sealed partial class MeetingControlDragData : GodotObject { } - -public partial class MeetingControl : PanelContainer +public sealed partial class MeetingControlDragData(MeetingControl meetingControl) : GodotObject { + public MeetingControl MeetingControl { get; set; } = meetingControl; +} + +[SceneTree] +public partial class MeetingControl : Control +{ + [Export] + public Meeting Meeting; + + public bool InSlot { get; set; } + public override Variant _GetDragData(Vector2 atPosition) { - GD.Print("CONTROL DRAG"); - var copy = Duplicate() as MeetingControl; - SetDragPreview(copy); + var preview = CreatePreview(); + SetDragPreview(preview); + GD.Print("asdasdasdasd as dasd"); + Visible = false; - return Variant.From(new MeetingControlDragData()); + InSlot = false; + + return Variant.From(new MeetingControlDragData(this)); + } + + public void StartDrag() + { + var preview = CreatePreview(); + var data = Variant.From(new MeetingControlDragData(this)); + + ForceDrag(data, preview); + } + + public override void _Notification(int what) + { + if (what == NotificationDragEnd) + { + GD.Print("Drag End"); + + if (InSlot) + { + GD.Print("Dropped in Slot"); + return; + } + + GD.Print("Dropped somewhere"); + + FindParent("Main").AddChild(Meeting); + Meeting.Position = GetGlobalMousePosition(); + QueueFree(); + } + } + + private Control CreatePreview() + { + var copy = Duplicate() as MeetingControl; + var preview = new Control(); + preview.AddChild(copy); + copy.Position = new Vector2(-Size.X / 2, -Size.Y / 2); + + return preview; } } diff --git a/MeetingControl.tscn b/MeetingControl.tscn index 4e6415b..e834745 100644 --- a/MeetingControl.tscn +++ b/MeetingControl.tscn @@ -1,16 +1,15 @@ [gd_scene format=3 uid="uid://do8ll0kylvrcn"] [ext_resource type="Script" uid="uid://ctl23v8cgy4k3" path="res://MeetingControl.cs" id="1_o5h3n"] -[ext_resource type="Texture2D" uid="uid://dyxftkkuf7h7w" path="res://icon.svg" id="1_o8u20"] +[ext_resource type="PackedScene" uid="uid://b2cpk0ef3rw87" path="res://MeetingControlGfx.tscn" id="1_o8u20"] -[node name="MeetingControl" type="PanelContainer" unique_id=508053904] -custom_minimum_size = Vector2(10.74, 9.49) +[node name="MeetingControl" type="Control" unique_id=778678487] +layout_mode = 3 +anchors_preset = 0 offset_right = 329.0 offset_bottom = 80.0 -size_flags_horizontal = 3 script = ExtResource("1_o5h3n") -[node name="Icon" type="Sprite2D" parent="." unique_id=1047834216] -position = Vector2(36.999996, 37) -scale = Vector2(0.390625, 0.390625) -texture = ExtResource("1_o8u20") +[node name="MeetingControlGFX" parent="." unique_id=1923695250 instance=ExtResource("1_o8u20")] +layout_mode = 0 +mouse_filter = 2 diff --git a/MeetingControlGfx.tscn b/MeetingControlGfx.tscn new file mode 100644 index 0000000..0147d46 --- /dev/null +++ b/MeetingControlGfx.tscn @@ -0,0 +1,14 @@ +[gd_scene format=3 uid="uid://b2cpk0ef3rw87"] + +[ext_resource type="Texture2D" uid="uid://dyxftkkuf7h7w" path="res://icon.svg" id="1_vkyb6"] + +[node name="MeetingControlGFX" type="PanelContainer" unique_id=1923695250] +custom_minimum_size = Vector2(10.74, 9.49) +offset_right = 330.0 +offset_bottom = 80.0 +size_flags_horizontal = 3 + +[node name="Icon" type="Sprite2D" parent="." unique_id=527110079] +position = Vector2(36.999996, 37) +scale = Vector2(0.390625, 0.390625) +texture = ExtResource("1_vkyb6") diff --git a/TimeSlot.cs b/TimeSlot.cs index 2f2ef6a..f8beec8 100644 --- a/TimeSlot.cs +++ b/TimeSlot.cs @@ -2,6 +2,8 @@ using Godot; public partial class TimeSlot : PanelContainer { + public MeetingControl MeetingControl { get; set; } + public override bool _CanDropData(Vector2 atPosition, Variant data) { GD.Print("DRAGGED OVERR!!!"); @@ -11,6 +13,24 @@ public partial class TimeSlot : PanelContainer public override void _DropData(Vector2 atPosition, Variant data) { - GD.Print("DROP"); + var meetingData = (MeetingControlDragData)data; + + MeetingControl = meetingData.MeetingControl; + meetingData.MeetingControl.InSlot = true; + MeetingControl.Reparent(this, false); + MeetingControl.Visible = true; + } + + public override void _Notification(int what) + { + if (what == NotificationDragBegin) + { + MouseFilter = MouseFilterEnum.Pass; + } + + if (what == NotificationDragEnd) + { + MouseFilter = MouseFilterEnum.Ignore; + } } } diff --git a/TimeSlot.tscn b/TimeSlot.tscn index 313ca9b..7db91f5 100644 --- a/TimeSlot.tscn +++ b/TimeSlot.tscn @@ -4,4 +4,6 @@ [node name="TimeSlot" type="PanelContainer" unique_id=979842204] custom_minimum_size = Vector2(0, 74) +offset_bottom = 80.0 +mouse_filter = 2 script = ExtResource("1_50jir") diff --git a/your are an ai ceo.csproj b/your are an ai ceo.csproj index 5a8f873..9898140 100644 --- a/your are an ai ceo.csproj +++ b/your are an ai ceo.csproj @@ -5,4 +5,7 @@ true yourareanaiceo - \ No newline at end of file + + + +