game.gd 769 B

1234567891011121314151617181920212223242526
  1. class_name Game
  2. extends Node
  3. @onready var _pause_menu := $InterfaceLayer/PauseMenu as PauseMenu
  4. func _unhandled_input(event: InputEvent) -> void:
  5. if event.is_action_pressed(&"toggle_fullscreen"):
  6. var mode := DisplayServer.window_get_mode()
  7. if mode == DisplayServer.WINDOW_MODE_FULLSCREEN or \
  8. mode == DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
  9. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
  10. else:
  11. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
  12. get_tree().root.set_input_as_handled()
  13. elif event.is_action_pressed(&"toggle_pause"):
  14. var tree := get_tree()
  15. tree.paused = not tree.paused
  16. if tree.paused:
  17. _pause_menu.open()
  18. else:
  19. _pause_menu.close()
  20. get_tree().root.set_input_as_handled()