mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-20 03:54:47 +00:00
✨ Use escape key to get back to main menu
This commit is contained in:
parent
3e28091661
commit
94fbf5c604
|
|
@ -30,7 +30,6 @@ func _ready():
|
|||
var has_authority = is_multiplayer_authority()
|
||||
set_process(has_authority)
|
||||
set_process_unhandled_input(has_authority)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
var mouse_mode = Input.get_mouse_mode()
|
||||
|
|
|
|||
32
main.tscn
32
main.tscn
|
|
@ -19,30 +19,38 @@ func _ready():
|
|||
$BootMenu/Multiplayer.join_server.connect(_join_server)
|
||||
|
||||
func _start_demo():
|
||||
if mode: mode.queue_free()
|
||||
mode = SINGLEPLAYER.instantiate()
|
||||
add_child(mode)
|
||||
_set_game_mode(SINGLEPLAYER.instantiate())
|
||||
$BootMenu.hide()
|
||||
|
||||
func _start_server(port, nickname):
|
||||
if mode: mode.queue_free()
|
||||
mode = MULTIPLAYER.instantiate()
|
||||
add_child(mode)
|
||||
_set_game_mode(MULTIPLAYER.instantiate())
|
||||
mode.start_server(port, nickname)
|
||||
$BootMenu.hide()
|
||||
|
||||
func _join_server(host, port, nickname):
|
||||
if mode: mode.queue_free()
|
||||
mode = MULTIPLAYER.instantiate()
|
||||
add_child(mode)
|
||||
_set_game_mode(MULTIPLAYER.instantiate())
|
||||
mode.connected_to_server.connect($BootMenu/Multiplayer._on_connected_to_server)
|
||||
mode.connection_failed.connect($BootMenu/Multiplayer._on_connection_failed)
|
||||
mode.join_server(host, port, nickname)
|
||||
|
||||
func _unhandled_input(event):
|
||||
# exit the program
|
||||
func _input(event):
|
||||
if event.is_action_pressed(\"exit\"):
|
||||
get_tree().quit()
|
||||
_set_game_mode(null)
|
||||
multiplayer.multiplayer_peer.close()
|
||||
$BootMenu.show()
|
||||
|
||||
func _set_game_mode(new_mode : Node):
|
||||
if mode != null:
|
||||
remove_child(mode)
|
||||
mode.queue_free()
|
||||
mode = new_mode
|
||||
if mode == null:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
add_child(mode)
|
||||
|
||||
func _unhandled_input(event):
|
||||
# switch window mode
|
||||
if event.is_action_pressed(\"window_mode\"):
|
||||
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
|
|
|
|||
Loading…
Reference in a new issue