## freeftf ## Copyright (C) 2024 Patrick_Pluto ## ## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License along with this program. If not, see . extends Control var elevated = false func _ready(): multiplayer.connected_to_server.connect(_on_connected_ok) if Server.is_server: $player_customization/ip.hide() $player_customization/ip.text = "localhost" $player_customization/ip.editable = false $start/start.show() $start/start.disabled = false $player_list/list.text = " " func _process(delta): if Server.is_server: Server.sync_playerlist.rpc($player_list/list.text, multiplayer.get_unique_id()) if Server.is_server and !elevated: _ready() Server.send_playerinfo($player_customization/name.text, multiplayer.get_unique_id()) elevated = true func _on_start_pressed(): Server.start_game.rpc(Server.players) func _input(event): if Input.is_action_just_pressed("escape"): Game.reset() Server.reset() get_tree().change_scene_to_file("res://menus/main_menu.tscn") func _on_join_pressed(): if $player_customization/name.text != "" and $player_customization/name.text.length() <= 20 and $player_customization/ip.text != "": if !Server.is_server: Server.join_game($player_customization/ip.text) func _on_connected_ok(): $player_customization/join.hide() $player_customization/join.disabled = true $player_customization/name.editable = false $player_customization/ip.editable = false await get_tree().create_timer(1).timeout Server.send_playerinfo.rpc($player_customization/name.text, multiplayer.get_unique_id())