breadwinner/scenes/ui/report/report.gd

64 lines
2 KiB
GDScript3
Raw Normal View History

extends Node
# Node references matching the structure in kép.png
@onready var ui_control = $Control
@onready var title_input = $Control/MarginContainer/VboxContainer/TitleInput
@onready var body_input = $Control/MarginContainer/VboxContainer/BodyInput
@onready var send_button = $Control/MarginContainer/VboxContainer/Send
@onready var cancel_button = $Control/MarginContainer/VboxContainer/Cancel
func _ready():
# Hide the UI when the game starts
ui_control.visible = false
# Connect the button pressed signals to our functions
send_button.pressed.connect(_on_send_pressed)
cancel_button.pressed.connect(_on_cancel_pressed)
func _input(event):
# Listen for the F3 key press to toggle the menu
if event is InputEventKey and event.pressed and not event.echo:
if event.keycode == KEY_F3:
toggle_bug_report_screen()
func toggle_bug_report_screen():
ui_control.visible = !ui_control.visible
if ui_control.visible:
# Automatically focus the title input so the player can just start typing
title_input.grab_focus()
else:
# Clear out the text if the player closes the screen using F3
clear_inputs()
func _on_send_pressed():
var title_text = title_input.text.strip_edges()
var body_text = body_input.text.strip_edges()
# Basic validation to ensure they don't send an empty report
if title_text.is_empty() or body_text.is_empty():
print("Report incomplete: Please provide both a title and a description.")
return
# --- YOUR SENDING LOGIC GOES HERE ---
# e.g., HTTPRequest to a Discord webhook, Trello API, or custom backend
print("Sending Bug Report...")
print("Title: ", title_text)
print("Body: ", body_text)
# Close the menu after successfully sending
close_and_clear()
func _on_cancel_pressed():
# Close the menu without sending
close_and_clear()
func close_and_clear():
clear_inputs()
ui_control.visible = false
func clear_inputs():
# Resets the text fields for the next time the screen is opened
title_input.text = ""
body_input.text = ""