From 524948c8000d8bf037505cc1f50492c8b7541cd1 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Thu, 6 Jun 2024 15:11:55 -0400 Subject: [PATCH] Bug info dialogue box now exists in-game, and offers the same functionality as the editor popup. --- Scenes/bugbot_player.gd | 8 +++++- UI/bug_info.gd | 33 +++++++++++++++++++++++ UI/bug_info.tscn | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 UI/bug_info.gd create mode 100644 UI/bug_info.tscn diff --git a/Scenes/bugbot_player.gd b/Scenes/bugbot_player.gd index 05b6f53..f22d771 100644 --- a/Scenes/bugbot_player.gd +++ b/Scenes/bugbot_player.gd @@ -377,7 +377,13 @@ func __place_marker(_position:Vector3, _normal:Vector3) -> void: process_mode = Node.PROCESS_MODE_PAUSABLE func __pop_up_marker_info(_collider:BugInfoCollider, _position:Vector3, _normal:Vector3) -> void: - print(_collider.bug_info.title) + var bug_info_dialogue : BugbotBugInfoDialogue = preload("res://addons/Bugbot/UI/bug_info.tscn").instantiate() + add_child(bug_info_dialogue) + bug_info_dialogue.bug_info = _collider.bug_info + process_mode = Node.PROCESS_MODE_PAUSABLE + bug_info_dialogue.tree_exited.connect(__on_bug_info_dialogue_closed) +func __on_bug_info_dialogue_closed() -> void: + process_mode = Node.PROCESS_MODE_ALWAYS func __bug_report_form_data_prepared(tag_lists:Array) -> void: diff --git a/UI/bug_info.gd b/UI/bug_info.gd new file mode 100644 index 0000000..8960efe --- /dev/null +++ b/UI/bug_info.gd @@ -0,0 +1,33 @@ +class_name BugbotBugInfoDialogue +extends Control + + +@onready var __bug_info_title_label : Label = $VBoxContainer/Title +@onready var __bug_info_severity_label : Label = $VBoxContainer/Severity +@onready var __bug_info_status_label : Label = $VBoxContainer/Status + +var bug_info : BugbotBugData = null : set = __set_bug_info +var stored_mouse_mode : Input.MouseMode + + +func _enter_tree() -> void: + stored_mouse_mode = Input.mouse_mode + Input.mouse_mode = Input.MouseMode.MOUSE_MODE_VISIBLE + +func _exit_tree() -> void: + Input.mouse_mode = stored_mouse_mode + + +func __set_bug_info(info:BugbotBugData) -> void: + bug_info = info + __bug_info_title_label.text = bug_info.title + __bug_info_severity_label.text = bug_info.severity + __bug_info_status_label.text = bug_info.status + + +func _on_open_in_browser_pressed() -> void: + OS.shell_open(BugbotServerAPI._create_new_server_api()._get_bug_url(bug_info)) + queue_free() + +func _on_close_pressed() -> void: + queue_free() diff --git a/UI/bug_info.tscn b/UI/bug_info.tscn new file mode 100644 index 0000000..7cb4f0e --- /dev/null +++ b/UI/bug_info.tscn @@ -0,0 +1,59 @@ +[gd_scene load_steps=3 format=3 uid="uid://bwm02lorpbpcy"] + +[ext_resource type="Theme" uid="uid://cw07kl24clcs0" path="res://addons/Bugbot/UI/bug_report_form.theme" id="1_8fgi2"] +[ext_resource type="Script" path="res://addons/Bugbot/UI/bug_info.gd" id="2_6br02"] + +[node name="BugInfo" type="ColorRect"] +process_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_8fgi2") +color = Color(0, 0, 0, 0.25) +script = ExtResource("2_6br02") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.1 +anchor_top = 0.7 +anchor_right = 0.9 +anchor_bottom = 0.9 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Bug summary" +vertical_alignment = 2 + +[node name="Severity" type="Label" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 1 +text = "Severity" +vertical_alignment = 2 + +[node name="Status" type="Label" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 1 +text = "Open" +vertical_alignment = 2 + +[node name="Buttons" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="OpenInBrowser" type="Button" parent="VBoxContainer/Buttons"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Open In Browser" + +[node name="Close" type="Button" parent="VBoxContainer/Buttons"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Close" + +[connection signal="pressed" from="VBoxContainer/Buttons/OpenInBrowser" to="." method="_on_open_in_browser_pressed" flags=6] +[connection signal="pressed" from="VBoxContainer/Buttons/Close" to="." method="_on_close_pressed" flags=6]