From b7a08e75110ac25596741166a88ca3eb471f41f9 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Tue, 28 May 2024 01:15:08 -0400 Subject: [PATCH] - Adjusted theming, including adding an error colour to text when a form field needs to be filled out. --- UI/bug_report_form.gd | 30 ++++++++++++++++++++++++++++-- UI/bug_report_form.theme | Bin 313 -> 448 bytes UI/bug_report_form.tscn | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/UI/bug_report_form.gd b/UI/bug_report_form.gd index 0e3a09e..f706f84 100644 --- a/UI/bug_report_form.gd +++ b/UI/bug_report_form.gd @@ -4,13 +4,21 @@ extends ColorRect signal submitted(map_name:String, bug_location:Vector3, bug_rotation:Vector3) signal cancelled +@onready var __product_name : Label = $Form/VBoxContainerLeft/GridContainer/ProductName +@onready var __version_label : Label = $Form/VBoxContainerLeft/GridContainer/VersionLabel @onready var __version_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/VersionButton +@onready var __hardware_label : MenuButton = $Form/VBoxContainerLeft/GridContainer/HardwareLabel @onready var __hardware_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/HardwareButton +@onready var __os_label : Label = $Form/VBoxContainerLeft/GridContainer/OSLabel @onready var __os_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/OSButton +@onready var __component_label : Label = $Form/VBoxContainerLeft/GridContainer/ComponentLabel @onready var __component_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/ComponentButton +@onready var __severity_label : Label = $Form/VBoxContainerLeft/GridContainer/SeverityLabel @onready var __severity_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/SeverityButton +@onready var __summary_label : Label = $Form/VBoxContainerRight/GridContainer/SummaryLabel @onready var __summary_text : LineEdit = $Form/VBoxContainerRight/GridContainer/SummaryText +@onready var __description_label : Label = $Form/VBoxContainerRight/GridContainer/DescriptionLabel @onready var __description_text : TextEdit = $Form/VBoxContainerRight/GridContainer/DescriptionText @onready var __submit_button : Button = $Form/VBoxContainerRight/SubmitButton @@ -23,7 +31,8 @@ var __label_groups : Array var __stored_mouse_mode : int var __server_api : BugbotServerAPI -const __button_disabled_message : StringName = &"Not available" +const __BUTTON_DISABLED_MESSAGE : StringName = &"Not available" +const __ERROR_TEXT_COLOUR : Color = Color(0.75, 0.0, 0.0) func _enter_tree(): @@ -40,6 +49,7 @@ func fill_tags(tag_list:Array): __label_groups.resize(BugbotServerAPI.BugbotTagArray.MAX) __label_groups = tag_list + __product_name.text = ProjectSettings.get_setting("application/config/name", "") __fill_item_list(__version_button, BugbotServerAPI.BugbotTagArray.VERSION) __fill_item_list(__hardware_button, BugbotServerAPI.BugbotTagArray.HARDWARE) __fill_item_list(__os_button, BugbotServerAPI.BugbotTagArray.OS) @@ -49,7 +59,7 @@ func fill_tags(tag_list:Array): func __fill_item_list(menu_button:MenuButton, label_group:int): var menu_options : Array = __label_groups[label_group] if menu_options.is_empty(): - menu_button.text = __button_disabled_message + menu_button.text = __BUTTON_DISABLED_MESSAGE menu_button.disabled = true else: var menu : PopupMenu = menu_button.get_popup() @@ -67,17 +77,33 @@ func _on_submit_button_pressed() -> void: var description_text : String = __description_text.text if summary_text.is_empty(): printerr("You must fill in a summary.") + __summary_label.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR) + __summary_text.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR) error_detected = true + else: + __summary_label.remove_theme_color_override("font_color") + __summary_text.remove_theme_color_override("font_color") + if description_text.is_empty(): printerr("You must fill in a description.") + __description_label.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR) + __description_text.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR) error_detected = true + else: + __description_label.remove_theme_color_override("font_color") + __description_text.remove_theme_color_override("font_color") var labels_to_be_added : Array # Check severity first, since this is a requirement. __get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.SEVERITY) if labels_to_be_added.is_empty(): printerr("You must select a severity level.") + __severity_label.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR) + __severity_button.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR) error_detected = true + else: + __severity_label.remove_theme_color_override("font_color") + __severity_button.remove_theme_color_override("font_color") if error_detected: __submit_button.disabled = false diff --git a/UI/bug_report_form.theme b/UI/bug_report_form.theme index d3254debf56e5f8298b8ba54ef445e720a03fbe4..91179ee55968cb83792a81b861bdae236c36674c 100644 GIT binary patch literal 448 zcmV;x0YCmyQ$s@n000005C8xv1ONc20RR9fwJ-f(DFgKk0OpfKH$acl0mCpcRY%Eq zbjE?gFBE3Cw%np7`vPp1NJ7}x&Du7$j8y{2PwS+G9+TLRfFIODtF%r5F#s|EHUQaw zhOY`r&Q~r*ANPw8I3N)D?V=opduNw@q3EOTbOEYgIQ&KRCX-Z8#7Xy0-0lgq5-zdFjLq-?Tvo{QUrh`h^qyS z4%ye zwVqtdW5&ip6nYMPJI)f0qhjZOG&Otc-mB}WC{=pJoL9n?Bj7cKmc@THtI z_{x2>akuCm$F^@)raS*D{1kT}r6MxpI$VH%{!T^hV+0z