way too many changes to list, oops. big rewrite.
This commit is contained in:
@ -3,18 +3,35 @@ class_name ServerForm extends PanelContainer
|
||||
signal connect_button_pressed
|
||||
signal host_button_pressed
|
||||
|
||||
@export var ip_entry: LineEdit
|
||||
@export var port_entry: LineEdit
|
||||
@export var host_button: Button
|
||||
@export var join_button: Button
|
||||
@export var ip_field: HBoxContainer
|
||||
@export var port_field: HBoxContainer
|
||||
@export var players_field: HBoxContainer
|
||||
@export var start_button: Button
|
||||
|
||||
func _on_host_pressed() -> void:
|
||||
host_button_pressed.emit()
|
||||
queue_free()
|
||||
func _on_connect_pressed() -> void:
|
||||
connect_button_pressed.emit()
|
||||
queue_free()
|
||||
var menu: int = 0
|
||||
var hosting: bool = false
|
||||
|
||||
func get_server_ip() -> String:
|
||||
return $VBoxContainer/HBoxContainer/ServerIP.text
|
||||
func get_server_port() -> String:
|
||||
return $VBoxContainer/HBoxContainer2/ServerPort.text
|
||||
var ip: String :
|
||||
get:
|
||||
return ip_entry.text if ip_entry.text != "" else "localhost"
|
||||
set(_value):
|
||||
return
|
||||
|
||||
var port: int :
|
||||
get:
|
||||
return int(port_entry.text) if port_entry.text != "" and port_entry.text.is_valid_int() else Data.DEFAULT_SERVER_PORT
|
||||
set(_value):
|
||||
return
|
||||
|
||||
var max_players: int :
|
||||
get:
|
||||
return int($VBoxContainer/PlayersField/HSlider.value)
|
||||
set(_value):
|
||||
return
|
||||
|
||||
|
||||
func _on_button_mouse_entered() -> void:
|
||||
@ -22,4 +39,47 @@ func _on_button_mouse_entered() -> void:
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
Game.scene_switch_main_menu()
|
||||
if menu == 0:
|
||||
Game.scene_switch_main_menu()
|
||||
else:
|
||||
menu -= 1
|
||||
host_button.visible = true
|
||||
join_button.visible = true
|
||||
ip_field.visible = false
|
||||
port_field.visible = false
|
||||
players_field.visible = false
|
||||
start_button.visible = false
|
||||
ip_entry.clear()
|
||||
port_entry.clear()
|
||||
|
||||
|
||||
func _on_host_button_pressed() -> void:
|
||||
menu += 1
|
||||
hosting = true
|
||||
host_button.visible = false
|
||||
join_button.visible = false
|
||||
port_field.visible = true
|
||||
players_field.visible = true
|
||||
start_button.visible = true
|
||||
|
||||
|
||||
func _on_join_button_pressed() -> void:
|
||||
menu += 1
|
||||
hosting = false
|
||||
host_button.visible = false
|
||||
join_button.visible = false
|
||||
ip_field.visible = true
|
||||
port_field.visible = true
|
||||
start_button.visible = true
|
||||
|
||||
|
||||
func _on_start_button_pressed() -> void:
|
||||
if hosting:
|
||||
host_button_pressed.emit()
|
||||
else:
|
||||
connect_button_pressed.emit()
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_h_slider_value_changed(value: float) -> void:
|
||||
$VBoxContainer/PlayersField/Label2.text = str(int(value))
|
||||
|
Reference in New Issue
Block a user