2024-08-05 22:35:50 +02:00
## freeftf
## Copyright (C) 2024 Patrick_Pluto
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## 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.
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## 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.
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-08-02 22:38:08 +02:00
2024-08-02 20:13:42 +02:00
extends Control
2024-08-05 22:35:50 +02:00
var elevated = false
2024-08-02 20:13:42 +02:00
func _ready ( ) :
2024-08-04 13:41:19 +02:00
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 :
2024-08-05 22:35:50 +02:00
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
2024-08-02 20:13:42 +02:00
func _on_start_pressed ( ) :
Server . start_game . rpc ( Server . players )
2024-08-03 22:24:08 +02:00
func _input ( event ) :
if Input . is_action_just_pressed ( " escape " ) :
get_tree ( ) . change_scene_to_file ( " res://menus/main_menu.tscn " )
2024-08-04 13:41:19 +02:00
func _on_join_pressed ( ) :
if $ player_customization / name . text != " " and $ player_customization / ip . text != " " :
if ! Server . is_server :
Server . join_game ( $ player_customization / ip . text )
$ player_customization / join . hide ( )
$ player_customization / join . disabled = true
$ player_customization / name . editable = false
$ player_customization / ip . editable = false
2024-08-05 22:35:50 +02:00
await get_tree ( ) . create_timer ( 1 ) . timeout
2024-08-04 13:41:19 +02:00
Server . send_playerinfo . rpc ( $ player_customization / name . text , multiplayer . get_unique_id ( ) )