fix uncaught errors in dev console

This commit is contained in:
Rowan 2025-05-05 17:20:53 -05:00
parent e74a317078
commit d7eea05820
4 changed files with 13 additions and 7 deletions

View file

@ -0,0 +1 @@
uid://bvvocjakigicu

View file

@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://b8xytvsmqsf55"] [gd_scene load_steps=4 format=3 uid="uid://b8xytvsmqsf55"]
[ext_resource type="Script" path="res://addons/dev_console/dev_console.ts" id="1_3ukun"] [ext_resource type="Script" uid="uid://kxku2ly58ova" path="res://addons/dev_console/dev_console.ts" id="1_3ukun"]
[ext_resource type="Theme" uid="uid://p5gitjrllq0a" path="res://addons/dev_console/monospace.tres" id="2_0wrae"] [ext_resource type="Theme" uid="uid://p5gitjrllq0a" path="res://addons/dev_console/monospace.tres" id="2_0wrae"]
[ext_resource type="Script" path="res://addons/dev_console/autocomplete_line.ts" id="2_fq41p"] [ext_resource type="Script" uid="uid://bvvocjakigicu" path="res://addons/dev_console/autocomplete_line.ts" id="2_fq41p"]
[node name="CanvasLayer" type="CanvasLayer"] [node name="CanvasLayer" type="CanvasLayer"]
process_mode = 3 process_mode = 3

View file

@ -30,7 +30,6 @@ export default class DevConsole extends Control {
private history_index: number = -1 private history_index: number = -1
_ready(): void { _ready(): void {
this._toggle()
const method_names = Enumerable.from(new GArrayEnumerator(this.get_method_list())) const method_names = Enumerable.from(new GArrayEnumerator(this.get_method_list()))
.map((x: GDictionary) => x.get('name')) .map((x: GDictionary) => x.get('name'))
.filter((x: string) => !x.startsWith('_')) .filter((x: string) => !x.startsWith('_'))
@ -40,6 +39,8 @@ export default class DevConsole extends Control {
this, this,
this._submit_command this._submit_command
) )
this._hide()
} }
_input(event: InputEvent): void { _input(event: InputEvent): void {
@ -88,6 +89,7 @@ export default class DevConsole extends Control {
} }
async _show() { async _show() {
this.visible = true
await this.get_tree().process_frame.as_promise() await this.get_tree().process_frame.as_promise()
if (this.pause_when_open) { if (this.pause_when_open) {
this.get_tree().paused = true this.get_tree().paused = true
@ -98,20 +100,22 @@ export default class DevConsole extends Control {
} }
_hide() { _hide() {
this.visible = false
if (this.pause_when_open) { if (this.pause_when_open) {
this.get_tree().paused = false this.get_tree().paused = false
} }
this.input.text_submitted.disconnect(this.parse_callable) if (this.input.is_connected(this.input.text_submitted.get_name(), this.parse_callable as Callable)) {
this.input.text_submitted.disconnect(this.parse_callable)
}
this.input.release_focus() this.input.release_focus()
} }
async _toggle() { async _toggle() {
this._reset() this._reset()
this.visible = !this.visible if (!this.visible) {
if (this.visible) {
this._show() this._show()
} else { } else {
this._hide() this._hide()

View file

@ -0,0 +1 @@
uid://kxku2ly58ova