bazar_alea/client/scenes/DebugWindow.gd

92 lines
3.6 KiB
GDScript

extends Window
@export var node_players : Node = null:
set(value):
node_players = value
@export var node_me : Node = null:
set(value):
node_me = value
const MAX_MESSAGES_SHOW : int = 100
# Called when the node enters the scene tree for the first time.
func _ready():
$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.
func _process(_delta):
if node_players:
$TabContainer/Perso/VBoxContainer/HBoxContainer/Count.set_text(str(node_players.get_child_count()))
$TabContainer/Perso/VBoxContainer/HBoxContainer2/Id.set_text(str(Multi.get_id()))
if node_players.get_child_count() > 0:
var info:String = str(node_players.get_child(0).get_my_position()) + "\n" + str(node_players.get_child(0).get_my_rotation()) + "\n" + str(node_players.get_child(0).get_comment())
$TabContainer/Network/VBoxContainer/players/player0.set_text(info)
#print(str(node_players.get_child(0).get_my_position()) + " - " + str(node_players.get_child(0).get_my_rotation()) )
if node_me:
var info:String = str(node_me.get_child(0).get_my_position()) + " - " + str(node_me.get_child(0).get_my_rotation())
$TabContainer/Network/VBoxContainer/me/me.set_text(info)
var tmp:String = ""
tmp += "Anim: " + str(node_me.get_child(0).get_animation())
tmp += "\nGait: " + node_me.get_child(0).get_gait()
tmp += "\nStance: " + node_me.get_child(0).get_stance()
tmp += "\nRotation: " + node_me.get_child(0).get_rotation_mode()
tmp += "\nMovement: " + node_me.get_child(0).get_movement_state()
tmp += "\nComment:" + node_me.get_child(0).get_comment()
$TabContainer/Network/VBoxContainer/state/state.set_text(tmp)
func _on_close_requested():
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)