mirror of
https://port.numenaute.org/aleajactaest/bazar_alea.git
synced 2024-11-21 14:46:14 +00:00
improve debug windows
This commit is contained in:
parent
cda9e76f79
commit
a04ad8877e
3 changed files with 196 additions and 17 deletions
|
@ -1,5 +1,38 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
signal update_message(message)
|
||||||
|
|
||||||
|
@export var debug_console:bool = false:
|
||||||
|
get: return debug_console
|
||||||
|
set(value):
|
||||||
|
debug_console = value
|
||||||
|
|
||||||
|
@export var debug_app:bool = false:
|
||||||
|
get: return debug_app
|
||||||
|
set(value):
|
||||||
|
debug_app = value
|
||||||
|
|
||||||
|
@export var verbose_console:bool = false:
|
||||||
|
get: return verbose_console
|
||||||
|
set(value):
|
||||||
|
verbose_console = value
|
||||||
|
|
||||||
|
@export var verbose_app:bool = false:
|
||||||
|
get: return verbose_app
|
||||||
|
set(value):
|
||||||
|
verbose_app = value
|
||||||
|
|
||||||
|
@export var error_console:bool = false:
|
||||||
|
get: return error_console
|
||||||
|
set(value):
|
||||||
|
error_console = value
|
||||||
|
|
||||||
|
@export var error_app:bool = false:
|
||||||
|
get: return error_app
|
||||||
|
set(value):
|
||||||
|
error_app = value
|
||||||
|
|
||||||
|
|
||||||
#------------------ Player Enums ------------------#
|
#------------------ Player Enums ------------------#
|
||||||
# Demarche (Attend, Marche, Cours, sprint
|
# Demarche (Attend, Marche, Cours, sprint
|
||||||
enum GAIT {WAITING, WALKING , RUNNING , SPRINTING}
|
enum GAIT {WAITING, WALKING , RUNNING , SPRINTING}
|
||||||
|
@ -41,23 +74,34 @@ func get_time_only_text() -> String:
|
||||||
time['hour'], time['minute'], time['second'],
|
time['hour'], time['minute'], time['second'],
|
||||||
]
|
]
|
||||||
|
|
||||||
func msg_debug(format_string:String, array_text:Array) -> void:
|
func send_message_console(severity:String, format_string:String, array_text:Array) -> void:
|
||||||
var formattage = "%s DEBUG [%s:%d] " + format_string
|
var formattage = "%s %s [%s:%d] " + format_string
|
||||||
var frame = get_stack()[1]
|
var frame = get_stack()[2]
|
||||||
var param = [get_time_text(), frame.source, frame.line]
|
var param = [get_time_text(), severity, frame.source, frame.line]
|
||||||
param.append_array(array_text)
|
|
||||||
print( formattage % param )
|
|
||||||
|
|
||||||
func msg_info(format_string:String, array_text:Array) -> void:
|
|
||||||
var formattage = "%s INFO [%s:%d] " + format_string
|
|
||||||
var frame = get_stack()[1]
|
|
||||||
var param = [get_time_text(), frame.source, frame.line]
|
|
||||||
param.append_array(array_text)
|
param.append_array(array_text)
|
||||||
print( formattage % param )
|
print( formattage % param )
|
||||||
|
|
||||||
func msg_error(format_string:String, array_text:Array) -> void:
|
func send_message_app(severity:String, format_string:String, array_text:Array) -> void:
|
||||||
var formattage = "%s ERROR [%s:%d] " + format_string
|
var formattage = "%s %s [%s:%d] " + format_string
|
||||||
var frame = get_stack()[1]
|
var frame = get_stack()[2]
|
||||||
var param = [get_time_text(), frame.source, frame.line]
|
var param = [get_time_text(), severity, frame.source, frame.line]
|
||||||
param.append_array(array_text)
|
param.append_array(array_text)
|
||||||
print( formattage % param )
|
update_message.emit(formattage % param)
|
||||||
|
|
||||||
|
func msg_debug(format_string:String, array_text:Array) -> void:
|
||||||
|
if debug_console:
|
||||||
|
send_message_console("DEBUG", format_string, array_text)
|
||||||
|
if debug_app:
|
||||||
|
send_message_app("DEBUG", format_string, array_text)
|
||||||
|
|
||||||
|
func msg_info(format_string:String, array_text:Array) -> void:
|
||||||
|
if verbose_console:
|
||||||
|
send_message_console("INFO", format_string, array_text)
|
||||||
|
if verbose_app:
|
||||||
|
send_message_app("INFO", format_string, array_text)
|
||||||
|
|
||||||
|
func msg_error(format_string:String, array_text:Array) -> void:
|
||||||
|
if error_console:
|
||||||
|
send_message_console("ERROR", format_string, array_text)
|
||||||
|
if error_app:
|
||||||
|
send_message_app("ERROR", format_string, array_text)
|
||||||
|
|
|
@ -10,10 +10,17 @@ extends Window
|
||||||
set(value):
|
set(value):
|
||||||
node_me = value
|
node_me = value
|
||||||
|
|
||||||
|
const MAX_MESSAGES_SHOW : int = 100
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
$TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/DConsole.button_pressed = Global.debug_console
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/VConsole.button_pressed = Global.verbose_console
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/EConsole.button_pressed = Global.error_console
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/DApplication.button_pressed = Global.debug_app
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/VApplication.button_pressed = Global.verbose_app
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/EApplication.button_pressed = Global.error_app
|
||||||
|
Global.update_message.connect(_update_messages)
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
@ -40,3 +47,45 @@ func _process(_delta):
|
||||||
|
|
||||||
func _on_close_requested():
|
func _on_close_requested():
|
||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_console_toggled(button_pressed):
|
||||||
|
Global.debug_console = button_pressed
|
||||||
|
|
||||||
|
|
||||||
|
func _on_application_toggled(button_pressed):
|
||||||
|
Global.debug_app = button_pressed
|
||||||
|
|
||||||
|
|
||||||
|
func _on_v_console_toggled(button_pressed):
|
||||||
|
Global.verbose_console = button_pressed
|
||||||
|
|
||||||
|
|
||||||
|
func _on_e_console_toggled(button_pressed):
|
||||||
|
Global.error_console = button_pressed
|
||||||
|
|
||||||
|
|
||||||
|
func _on_v_application_toggled(button_pressed):
|
||||||
|
Global.verbose_app = button_pressed
|
||||||
|
|
||||||
|
|
||||||
|
func _on_e_application_toggled(button_pressed):
|
||||||
|
Global.error_app = button_pressed
|
||||||
|
|
||||||
|
func _update_messages(message):
|
||||||
|
while $TabContainer/Log/VBoxContainer/TabContainer/Messages/ItemList.item_count >= MAX_MESSAGES_SHOW:
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Messages/ItemList.remove_item(0)
|
||||||
|
$TabContainer/Log/VBoxContainer/TabContainer/Messages/ItemList.add_item(message)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_item_list_gui_input(event) -> void:
|
||||||
|
""" copy to clipboard your selection (log) """
|
||||||
|
if event is InputEventKey:
|
||||||
|
if event.is_action_pressed("ui_copy"):
|
||||||
|
var tampon:String = ""
|
||||||
|
var next:String = ""
|
||||||
|
for item in $TabContainer/Log/VBoxContainer/TabContainer/Messages/ItemList.get_selected_items():
|
||||||
|
tampon += next + $TabContainer/Log/VBoxContainer/TabContainer/Messages/ItemList.get_item_text(item)
|
||||||
|
next = "\n"
|
||||||
|
DisplayServer.clipboard_set(tampon)
|
||||||
|
|
||||||
|
|
|
@ -103,4 +103,90 @@ text = "anim"
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Log" type="TabBar" parent="TabContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Log"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="TabContainer" type="TabContainer" parent="TabContainer/Log/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Messages" type="TabBar" parent="TabContainer/Log/VBoxContainer/TabContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ItemList" type="ItemList" parent="TabContainer/Log/VBoxContainer/TabContainer/Messages"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
select_mode = 1
|
||||||
|
allow_rmb_select = true
|
||||||
|
same_column_width = true
|
||||||
|
|
||||||
|
[node name="Config" type="TabBar" parent="TabContainer/Log/VBoxContainer/TabContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VBox" type="VBoxContainer" parent="TabContainer/Log/VBoxContainer/TabContainer/Config"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="DConsole" type="CheckButton" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Envoie les messages de debug vers la console"
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
|
[node name="VConsole" type="CheckButton" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Envoie les messages d'information vers la console"
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
|
[node name="EConsole" type="CheckButton" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Envoie les messages d'erreur vers la console"
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
|
[node name="HSeparator" type="HSeparator" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="DApplication" type="CheckButton" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Envoie les messages de debug vers l'application"
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
|
[node name="VApplication" type="CheckButton" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Envoie les messages d'information vers l'application"
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
|
[node name="EApplication" type="CheckButton" parent="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Envoie les messages d'erreur vers l'application"
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
|
||||||
|
[connection signal="gui_input" from="TabContainer/Log/VBoxContainer/TabContainer/Messages/ItemList" to="." method="_on_item_list_gui_input"]
|
||||||
|
[connection signal="toggled" from="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/DConsole" to="." method="_on_console_toggled"]
|
||||||
|
[connection signal="toggled" from="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/VConsole" to="." method="_on_v_console_toggled"]
|
||||||
|
[connection signal="toggled" from="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/EConsole" to="." method="_on_e_console_toggled"]
|
||||||
|
[connection signal="toggled" from="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/DApplication" to="." method="_on_application_toggled"]
|
||||||
|
[connection signal="toggled" from="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/VApplication" to="." method="_on_v_application_toggled"]
|
||||||
|
[connection signal="toggled" from="TabContainer/Log/VBoxContainer/TabContainer/Config/VBox/EApplication" to="." method="_on_e_application_toggled"]
|
||||||
|
|
Loading…
Reference in a new issue