extends MarginContainer func _ready(): $Home.show() $Settings.hide() func _on_Home_setting_pressed(): $Home.hide() $Settings.show() $Help.hide() func _on_Settings_return_pressed(): $Home.show() $Settings.hide() $Help.show() func _on_Home_play_pressed(): if not get_tree().paused: pause() else: play() func _input(event): if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED and event is InputEventKey: accept_event() if event.is_action_pressed("ui_test"): print( "Event: ui_test" ) if event.is_action_pressed("ui_quit"): get_tree().quit() if event.is_action_pressed("ui_reload"): if not $Settings.visible: get_tree().reload_current_scene() if event.is_action_pressed("ui_pause") and not event.is_echo(): if not $Settings.visible: if not get_tree().paused: pause() else: play() # ---------------------------------- # Capturing/Freeing the cursor # if Input.is_action_just_pressed("ui_free_cursor"): # if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: # Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) # else: # Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) # ---------------------------------- func pause(): get_tree().paused = true show_menu() func play(): get_tree().paused = false hide_menu() func show_menu(): $Home.show() $Settings.hide() $HUD.modulate.a = 0.5 Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) func hide_menu(): $Settings.hide() $Home.hide() $Help.show() $HUD.modulate.a = 1.0 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) func _on_Settings_font_changed( value ): $HUD.get_theme().default_font.size = value