diff --git a/UI/floating_menu.gd b/UI/floating_menu.gd new file mode 100644 index 00000000..7de51c90 --- /dev/null +++ b/UI/floating_menu.gd @@ -0,0 +1,86 @@ +extends GDSubMenuButton +class_name GDFloatingMenu + +const COL_ON := Color.LIGHT_GREEN +const COL_OFF := Color.LIGHT_SALMON + +@onready var indicators: Control = %indicators +@onready var ind_stream: TextureRect = %ind_stream +@onready var ind_mic: TextureRect = %ind_mic +@onready var ind_pixelate: TextureRect = %ind_pixelate +@onready var ind_browser: TextureRect = %ind_browser + +var is_anchored := true +var anchored_position: Vector2 + +func start(_main_menu_button: GDSubMenuButton = null) -> void: + anchored_position = position + var _parent: Control = get_parent() + _parent.resized.connect(func(): calculate_anchored_pos(); is_anchored = false) + generate_panels_buttons() + super(self) + start_indicators() + +func start_indicators() -> void: + # TODO: Setup NO-OBS-WS Stuff + + var tot = indicators.get_child_count() + for i in tot: + var ind: TextureRect = indicators.get_child(i) + ind.show() + ind.position = (size/2 - ind.size/2) + ind.position += Vector2.from_angle(TAU*i/tot + PI/2) * (size.x/2 - ind.size.x/2) + + pass + +func generate_panels_buttons() -> void: + # TODO: Generate Panels? + pass + +func _process(d: float) -> void: + super(d) + if not is_anchored and not is_dragged: + position = position.lerp(anchored_position, d*10) + if position.distance_squared_to(anchored_position) < 1: + position = anchored_position + is_anchored = true + +func _on_gui_input(event: InputEvent) -> void: + super(event) + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if not event.is_pressed(): + is_anchored = false + calculate_anchored_pos() + if event is InputEventMouseMotion and is_mouse_click_down: + if is_open: + expand_menu(false) + +func calculate_anchored_pos() -> void: + var m_pos := global_position + size/2.0 + var w_size := get_window().size / get_tree().root.content_scale_factor + + if min(m_pos.x, abs(w_size.x - m_pos.x)) < min(m_pos.y, abs(w_size.y - m_pos.y)): + closest_edge = Edge.LEFT if m_pos.x < abs(w_size.x - m_pos.x) else Edge.RIGHT + else: + closest_edge = Edge.UP if m_pos.y < abs(w_size.y - m_pos.y) else Edge.BOT + + match closest_edge: + Edge.UP: + anchored_position = Vector2(position.x, 0) + parent_dir = Vector2.DOWN + Edge.RIGHT: + anchored_position = Vector2(w_size.x - size.x, position.y) + parent_dir = Vector2.LEFT + Edge.BOT: + anchored_position = Vector2(position.x, w_size.y - size.y) + parent_dir = Vector2.UP + Edge.LEFT: + anchored_position = Vector2(0, position.y) + parent_dir = Vector2.RIGHT + + anchored_position = anchored_position.clamp(Vector2(), Vector2(w_size)-size) + +#region Hnadle Button Functions + +#endregion diff --git a/UI/floating_menu.gd.uid b/UI/floating_menu.gd.uid new file mode 100644 index 00000000..fbcb2428 --- /dev/null +++ b/UI/floating_menu.gd.uid @@ -0,0 +1 @@ +uid://cj6hogd55ju8g diff --git a/UI/floating_menu.tscn b/UI/floating_menu.tscn new file mode 100644 index 00000000..fa7e19f0 --- /dev/null +++ b/UI/floating_menu.tscn @@ -0,0 +1,210 @@ +[gd_scene format=3 uid="uid://bndydwe6rrb6p"] + +[ext_resource type="Script" uid="uid://cj6hogd55ju8g" path="res://UI/floating_menu.gd" id="1_eeo1l"] +[ext_resource type="Theme" uid="uid://b40wl3ulr08bk" path="res://UI/assets/custom_themes/floating_menu.tres" id="1_qghrq"] +[ext_resource type="Texture2D" uid="uid://bdil2rqv4x61g" path="res://UI/assets/godot.png" id="2_6cwdq"] +[ext_resource type="Texture2D" uid="uid://ds4f25alxa2ts" path="res://UI/assets/bootstrap/record2-fill.png" id="4_o0p5c"] +[ext_resource type="Texture2D" uid="uid://y855ko8d05b2" path="res://UI/assets/font_awesome/microphone-lines.svg" id="5_ttodq"] +[ext_resource type="Texture2D" uid="uid://6d7nud03gpul" path="res://UI/assets/pixelate.png" id="6_6cwdq"] +[ext_resource type="Texture2D" uid="uid://sabs3odgmwr8" path="res://UI/assets/font_awesome/firefox-browser.svg" id="7_o0p5c"] +[ext_resource type="Texture2D" uid="uid://drvtl6m84uqgv" path="res://UI/assets/simple/obsstudio.svg" id="8_k8nf3"] +[ext_resource type="Script" uid="uid://8715vyt7prmd" path="res://lib/UI/GDSubMenuButton.gd" id="8_ttodq"] +[ext_resource type="Texture2D" uid="uid://d2i8l1wlbp3on" path="res://UI/assets/font_awesome/person-running.svg" id="10_liuj8"] +[ext_resource type="Texture2D" uid="uid://c4k4skgijfubi" path="res://UI/assets/font_awesome/stopwatch.svg" id="11_ohje3"] +[ext_resource type="Texture2D" uid="uid://bw4n42uub1rlj" path="res://UI/assets/bootstrap/person-bounding-box.png" id="12_05x4r"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_o0p5c"] +bg_color = Color(0.08627451, 0.078431375, 0.078431375, 0.5058824) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.015686275, 0.63529414, 0.39607844, 1) +border_blend = true +corner_radius_top_left = 32 +corner_radius_top_right = 32 +corner_radius_bottom_right = 32 +corner_radius_bottom_left = 32 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ttodq"] +bg_color = Color(0.0850918, 0.0792672, 0.0792826, 0.505882) +border_width_left = 4 +border_width_top = 4 +border_width_right = 4 +border_width_bottom = 4 +border_color = Color(1, 1, 1, 1) +border_blend = true +corner_radius_top_left = 32 +corner_radius_top_right = 32 +corner_radius_bottom_right = 32 +corner_radius_bottom_left = 32 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yr1rr"] +bg_color = Color(0.14901961, 0.05490196, 0.07450981, 0.9137255) +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +border_color = Color(0.015686275, 0.63529414, 0.39607844, 1) +border_blend = true +corner_radius_top_left = 32 +corner_radius_top_right = 32 +corner_radius_bottom_right = 32 +corner_radius_bottom_left = 32 + +[node name="FloatingMenu" type="Button" unique_id=56646671] +custom_minimum_size = Vector2(64, 64) +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -64.0 +offset_top = 94.0 +offset_bottom = 158.0 +grow_horizontal = 0 +theme = ExtResource("1_qghrq") +theme_override_colors/font_color = Color(1, 1, 1, 0.36862746) +theme_override_colors/icon_normal_color = Color(1, 1, 1, 0.36862746) +theme_override_colors/icon_hover_color = Color(1, 1, 1, 0.74509805) +theme_override_colors/icon_hover_pressed_color = Color(1, 0.627451, 0.47843137, 1) +theme_override_styles/normal = SubResource("StyleBoxFlat_o0p5c") +theme_override_styles/pressed = SubResource("StyleBoxFlat_ttodq") +theme_override_styles/hover = SubResource("StyleBoxFlat_yr1rr") +icon = ExtResource("2_6cwdq") +icon_alignment = 1 +expand_icon = true +script = ExtResource("1_eeo1l") +expand_on_hover = false +is_radial = true +anim_delay = 0.02 +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="indicators" type="Control" parent="." unique_id=248790108] +unique_name_in_owner = true +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="ind_stream" type="TextureRect" parent="indicators" unique_id=1864576166] +unique_name_in_owner = true +custom_minimum_size = Vector2(16, 16) +layout_mode = 0 +offset_top = 48.0 +offset_right = 16.0 +offset_bottom = 64.0 +texture = ExtResource("4_o0p5c") +expand_mode = 1 +stretch_mode = 5 + +[node name="ind_mic" type="TextureRect" parent="indicators" unique_id=284184449] +unique_name_in_owner = true +custom_minimum_size = Vector2(16, 16) +layout_mode = 0 +offset_left = 16.0 +offset_top = 48.0 +offset_right = 32.0 +offset_bottom = 64.0 +texture = ExtResource("5_ttodq") +expand_mode = 1 +stretch_mode = 5 + +[node name="ind_pixelate" type="TextureRect" parent="indicators" unique_id=2102377562] +unique_name_in_owner = true +custom_minimum_size = Vector2(16, 16) +layout_mode = 0 +offset_left = 32.0 +offset_top = 48.0 +offset_right = 48.0 +offset_bottom = 64.0 +texture = ExtResource("6_6cwdq") +expand_mode = 1 +stretch_mode = 5 + +[node name="ind_browser" type="TextureRect" parent="indicators" unique_id=79342793] +unique_name_in_owner = true +custom_minimum_size = Vector2(16, 16) +layout_mode = 0 +offset_left = 48.0 +offset_top = 48.0 +offset_right = 64.0 +offset_bottom = 64.0 +texture = ExtResource("7_o0p5c") +expand_mode = 1 +stretch_mode = 5 + +[node name="btn_obs" type="Button" parent="." unique_id=1315951603] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +icon = ExtResource("8_k8nf3") +script = ExtResource("8_ttodq") +fold_on_child_button_pressed = false +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_run_obs" type="Button" parent="btn_obs" unique_id=1012049771] +unique_name_in_owner = true +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +icon = ExtResource("10_liuj8") +script = ExtResource("8_ttodq") +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_step_away" type="Button" parent="btn_obs" unique_id=1452458544] +unique_name_in_owner = true +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +icon = ExtResource("11_ohje3") +script = ExtResource("8_ttodq") +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_tuber" type="Button" parent="btn_obs" unique_id=118706136] +unique_name_in_owner = true +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +icon = ExtResource("12_05x4r") +script = ExtResource("8_ttodq") +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_chat" type="Button" parent="." unique_id=1509888398] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("8_ttodq") +fold_on_child_button_pressed = false +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_user_list" type="Button" parent="." unique_id=655134427] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("8_ttodq") +fold_on_child_button_pressed = false +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_settings" type="Button" parent="." unique_id=992431192] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("8_ttodq") +fold_on_child_button_pressed = false +metadata/_custom_type_script = "uid://8715vyt7prmd" + +[node name="btn_end" type="Button" parent="." unique_id=59540475] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("8_ttodq") +fold_on_child_button_pressed = false +metadata/_custom_type_script = "uid://8715vyt7prmd"