Bugbot/UI/bug_report_form.gd

45 lines
1.9 KiB
GDScript

class_name BugReportForm
extends ColorRect
@onready var __version_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/VersionButton
@onready var __hardware_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/HardwareButton
@onready var __os_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/OSButton
@onready var __component_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/ComponentButton
@onready var __severity_button : MenuButton = $Form/VBoxContainerLeft/GridContainer/SeverityButton
var __version_items : Array
var __hardware_items : Array
var __os_items : Array
var __component_items : Array
var __severity_items : Array
var __stored_mouse_mode : int
const __button_disabled_message : StringName = &"Not available"
func _enter_tree():
__stored_mouse_mode = Input.mouse_mode
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _exit_tree():
Input.mouse_mode = __stored_mouse_mode
func fill_tags(tag_list:Array):
__fill_item_list(__version_button, __version_items, tag_list[BugbotServerAPI.BugbotTagArray.VERSION])
__fill_item_list(__hardware_button, __hardware_items, tag_list[BugbotServerAPI.BugbotTagArray.HARDWARE])
__fill_item_list(__os_button, __os_items, tag_list[BugbotServerAPI.BugbotTagArray.OS])
__fill_item_list(__component_button, __component_items, tag_list[BugbotServerAPI.BugbotTagArray.COMPONENT])
__fill_item_list(__severity_button, __severity_items, tag_list[BugbotServerAPI.BugbotTagArray.SEVERITY])
func __fill_item_list(menu_button:MenuButton, menu_options:Array, tag_list:Array):
menu_options = tag_list
if menu_options.is_empty():
menu_button.text = __button_disabled_message
menu_button.disabled = true
else:
var menu : PopupMenu = menu_button.get_popup()
for i in menu_options.size():
menu.add_item(menu_options[i]["name"], i)
menu.id_pressed.connect(func(id:int): menu_button.text = menu_options[id]["name"])