Introduced console and bug fixes
parent
aaa928e660
commit
00ef404d91
|
@ -35,4 +35,15 @@ text = "Start"
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="ConsoleOutput" type="TextEdit" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchor_top = 0.7
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
readonly = true
|
||||||
|
caret_moving_by_right_click = false
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
[connection signal="pressed" from="Lobby/StartButton" to="." method="_on_StartButton_pressed"]
|
[connection signal="pressed" from="Lobby/StartButton" to="." method="_on_StartButton_pressed"]
|
||||||
|
|
|
@ -2,27 +2,48 @@ extends Node
|
||||||
|
|
||||||
|
|
||||||
const PORT : int = 9374
|
const PORT : int = 9374
|
||||||
|
var console_output : TextEdit = null
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
get_tree().connect("connected_to_server", self, "_connected_to_server")
|
get_tree().connect("connected_to_server", self, "_connected_to_server")
|
||||||
get_tree().connect("server_disconnected", self, "_server_disconnected")
|
get_tree().connect("server_disconnected", self, "_server_disconnected")
|
||||||
get_tree().connect("connection_failed", self, "_connection_failed")
|
get_tree().connect("connection_failed", self, "_connection_failed")
|
||||||
|
console_output = $ConsoleOutput
|
||||||
|
|
||||||
|
func _process(delta : float) -> void:
|
||||||
|
if Input.is_action_just_pressed("toggle_console"):
|
||||||
|
self.toggle_console()
|
||||||
|
|
||||||
func _connected_to_server() -> void:
|
func _connected_to_server() -> void:
|
||||||
print("Connected to server") # Let the server know all about us (eg name)
|
self.console_print("Connected to server") # Let the server know all about us (eg name)
|
||||||
|
|
||||||
func _server_disconnected() -> void:
|
func _server_disconnected() -> void:
|
||||||
print("Disconnected from server") # Kick us out the game and bring back the lobby (if applicable)
|
var button : Button = $Lobby/StartButton
|
||||||
|
if button:
|
||||||
|
button.disabled = false
|
||||||
|
else:
|
||||||
|
self.console_print("Tried to re-enable start button, but the start button could not be found")
|
||||||
|
self.console_print("Disconnected from server") # Kick us out the game and bring back the lobby (if applicable)
|
||||||
|
|
||||||
func _connection_failed() -> void:
|
func _connection_failed() -> void:
|
||||||
print("Connection Error")
|
var button : Button = $Lobby/StartButton
|
||||||
|
button.disabled = false
|
||||||
|
self.console_print("Connection Error")
|
||||||
|
|
||||||
|
func console_print(text : String) -> void:
|
||||||
|
console_output.text += "\n" + text
|
||||||
|
console_output.cursor_set_line(console_output.get_line_count())
|
||||||
|
print(text)
|
||||||
|
|
||||||
|
func toggle_console() -> bool:
|
||||||
|
console_output.visible = !console_output.visible
|
||||||
|
return console_output.visible
|
||||||
|
|
||||||
func _on_StartButton_pressed() -> void:
|
func _on_StartButton_pressed() -> void:
|
||||||
|
var button : Button = $Lobby/StartButton
|
||||||
var ip_addr : String = $Lobby/IPLineEdit.text
|
var ip_addr : String = $Lobby/IPLineEdit.text
|
||||||
|
button.disabled = true
|
||||||
var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new()
|
var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new()
|
||||||
peer.create_client(ip_addr, PORT)
|
peer.create_client(ip_addr, PORT)
|
||||||
get_tree().set_network_peer(peer)
|
get_tree().set_network_peer(peer)
|
||||||
|
|
|
@ -19,6 +19,67 @@ config/name="Client"
|
||||||
run/main_scene="res://Scenes/RootNode.tscn"
|
run/main_scene="res://Scenes/RootNode.tscn"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
ui_accept={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_select={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_cancel={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_focus_next={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_focus_prev={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_page_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_page_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_home={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
ui_end={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ ]
|
||||||
|
}
|
||||||
|
toggle_console={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":39,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":33554431,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
|
|
Loading…
Reference in New Issue