mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 00:14:48 +00:00
✨ enforce static typing
This commit is contained in:
parent
675974150f
commit
20eb9824cd
36 changed files with 271 additions and 374 deletions
|
|
@ -9,22 +9,22 @@ script/source = "class_name BootMenu extends CanvasLayer
|
|||
|
||||
signal start_demo
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
$Settings.menu_pressed.connect(_on_menu_pressed)
|
||||
|
||||
func _on_demo_pressed():
|
||||
func _on_demo_pressed() -> void:
|
||||
start_demo.emit()
|
||||
|
||||
func _on_multiplayer_pressed():
|
||||
func _on_multiplayer_pressed() -> void:
|
||||
_show_menu($Multiplayer)
|
||||
|
||||
func _on_settings_pressed():
|
||||
func _on_settings_pressed() -> void:
|
||||
_show_menu($Settings)
|
||||
|
||||
func _on_quit_pressed():
|
||||
func _on_quit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
func _on_menu_pressed():
|
||||
func _on_menu_pressed() -> void:
|
||||
_show_menu($Main)
|
||||
|
||||
func _show_menu(menu : PanelContainer) -> void:
|
||||
|
|
@ -49,20 +49,20 @@ var _join_address : RegEx = RegEx.new()
|
|||
var _registered_ports : RegEx = RegEx.new()
|
||||
var _config_file : ConfigFile = ConfigFile.new()
|
||||
|
||||
signal start_server(port)
|
||||
signal join_server(host, port)
|
||||
signal start_server(port : int)
|
||||
signal join_server(host : String, port : int)
|
||||
|
||||
@onready var modal : Control = $Modal
|
||||
@onready var menu : CanvasLayer = get_parent()
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
# see https://datatracker.ietf.org/doc/html/rfc1700
|
||||
_registered_ports.compile(r'^(?:102[4-9]|10[3-9]\\d|1[1-9]\\d{2}|[2-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$')
|
||||
_join_address.compile(r'^(?<host>[a-zA-Z0-9.-]+)(:(?<port>:102[4-9]|10[3-9]\\d|1[1-9]\\d{2}|[2-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]))?$')
|
||||
_load_config()
|
||||
hide() # start hidden
|
||||
|
||||
func _load_config():
|
||||
func _load_config() -> void:
|
||||
var error : Error = _config_file.load(CONFIG_FILE_PATH)
|
||||
if error != OK:
|
||||
return
|
||||
|
|
@ -70,22 +70,22 @@ func _load_config():
|
|||
var profile_name : String = _config_file.get_value(\"profile\", \"name\", \"Newblood\")
|
||||
%ProfileName.text = profile_name
|
||||
|
||||
func _on_save_pressed():
|
||||
func _on_save_pressed() -> void:
|
||||
_config_file.set_value(\"profile\", \"name\", %ProfileName.text)
|
||||
_config_file.save(CONFIG_FILE_PATH)
|
||||
|
||||
func _on_menu_pressed():
|
||||
func _on_menu_pressed() -> void:
|
||||
hide()
|
||||
owner.get_node(\"Main\").show()
|
||||
|
||||
func _on_quit_pressed():
|
||||
func _on_quit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
func _on_host_pressed():
|
||||
var port = DEFAULT_PORT
|
||||
func _on_host_pressed() -> void:
|
||||
var port : int = DEFAULT_PORT
|
||||
# check for registered ports number matches
|
||||
if %ServerPort.text:
|
||||
var result = _registered_ports.search(%ServerPort.text)
|
||||
var result : RegExMatch = _registered_ports.search(%ServerPort.text)
|
||||
if result: # port is valid
|
||||
port = int(result.get_string())
|
||||
else: # port is not valid
|
||||
|
|
@ -94,23 +94,23 @@ func _on_host_pressed():
|
|||
|
||||
start_server.emit(port, %ProfileName.text)
|
||||
|
||||
func _on_join_pressed():
|
||||
var addr = [DEFAULT_HOST, DEFAULT_PORT]
|
||||
func _on_join_pressed() -> void:
|
||||
var addr : Array = [DEFAULT_HOST, DEFAULT_PORT]
|
||||
# validate join address input
|
||||
var result = _join_address.search(%JoinAddress.text)
|
||||
var result : RegExMatch = _join_address.search(%JoinAddress.text)
|
||||
if result: # address is valid
|
||||
addr[0] = result.get_string(\"host\")
|
||||
var rport = result.get_string(\"port\")
|
||||
var rport : String = result.get_string(\"port\")
|
||||
if rport: addr[1] = int(rport)
|
||||
|
||||
$Modal.show()
|
||||
join_server.emit(addr[0], addr[1], %ProfileName.text)
|
||||
|
||||
func _on_connected_to_server():
|
||||
func _on_connected_to_server() -> void:
|
||||
$Modal.hide()
|
||||
menu.hide()
|
||||
|
||||
func _on_connection_failed():
|
||||
func _on_connection_failed() -> void:
|
||||
$Modal.hide()
|
||||
"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,30 +5,29 @@ bg_color = Color(0.5, 0.5, 0.5, 0.25)
|
|||
|
||||
[sub_resource type="GDScript" id="GDScript_gbnwv"]
|
||||
resource_name = "Settings"
|
||||
script/source = "class_name Settings extends PanelContainer
|
||||
script/source = "extends PanelContainer
|
||||
|
||||
const WINDOW_MODE_OPTIONS = [DisplayServer.WINDOW_MODE_WINDOWED, DisplayServer.WINDOW_MODE_FULLSCREEN]
|
||||
|
||||
@onready var _game_settings : GameSettings = get_node(\"/root/GlobalSettings\")
|
||||
@onready var _game_settings : Settings = get_node(\"/root/GlobalSettings\")
|
||||
|
||||
signal menu_pressed
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
%FOVSpinBox.value = _game_settings.fov
|
||||
%SensitivitySpinBox.value = _game_settings.mouse_sensitivity
|
||||
var window_mode : int = 1 if _game_settings.fullscreen else 0
|
||||
%InvertedYCheckbox.button_pressed = _game_settings.inverted_y_axis
|
||||
%WindowModeOptionButton.select(window_mode)
|
||||
|
||||
func _on_save_pressed():
|
||||
func _on_save_pressed() -> void:
|
||||
_game_settings.fov = %FOVSpinBox.value
|
||||
_game_settings.mouse_sensitivity = %SensitivitySpinBox.value
|
||||
_game_settings.inverted_y_axis = %InvertedYCheckbox.button_pressed
|
||||
_game_settings.fullscreen = %WindowModeOptionButton.selected == 1
|
||||
_game_settings.save_to_file()
|
||||
|
||||
|
||||
func _on_menu_pressed():
|
||||
func _on_menu_pressed() -> void:
|
||||
menu_pressed.emit()
|
||||
"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue