home scene

This commit is contained in:
Nordup 2024-11-21 05:20:31 +04:00
parent 5fe170dfc6
commit cce0bedbb1
21 changed files with 559 additions and 131 deletions

View file

@ -0,0 +1,26 @@
extends Node
signal logged(msg: String)
signal error(msg: String)
const ERROR_CLR = Color.RED
const WARN_CLR = Color.YELLOW
const SILENT_CLR = Color.DIM_GRAY
func logr(msg: Variant) -> void:
print_rich(str(msg))
logged.emit(str(msg))
func logerr(msg: Variant) -> void:
printerr(str(msg))
var rich_clr = "[color=%s]%s[/color]" % [Color.RED.to_html(), str(msg)]
logged.emit(rich_clr)
error.emit(msg)
func logclr(msg: Variant, color: Color) -> void:
var rich_clr = "[color=%s]%s[/color]" % [color.to_html(), str(msg)]
print_rich(rich_clr)
logged.emit(rich_clr)

View file

@ -0,0 +1,14 @@
extends RichTextLabel
func _ready() -> void:
Debug.logged.connect(add_log)
meta_clicked.connect(on_meta_clicked)
func add_log(msg: String) -> void:
append_text(msg + "\n")
func on_meta_clicked(meta) -> void:
OS.shell_open(str(meta))

View file

@ -0,0 +1,47 @@
extends Node
@export var window: Window
var window_visible
var mouse_mode: int = Input.MOUSE_MODE_VISIBLE
func _ready() -> void:
window_hide()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("open_debug") and not event.is_echo():
if window_visible:
window_hide()
else:
window_show()
func _on_window_window_input(event: InputEvent) -> void:
_input(event)
func _on_window_close_requested() -> void:
window_hide()
func _on_window_focus_exited() -> void:
window_hide()
func window_show() -> void:
window.show()
window_visible = true
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
mouse_mode = Input.MOUSE_MODE_CAPTURED
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
mouse_mode = Input.MOUSE_MODE_VISIBLE
func window_hide() -> void:
window.hide()
window_visible = false
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)