hud.gd 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. extends Control
  2. ## The 3D viewport's shrink factor. For instance, 1 is full resolution,
  3. ## 2 is half resolution and 4 is quarter resolution. Lower values look
  4. ## sharper but are slower to render.
  5. var scale_factor := 1
  6. var filter_mode := Viewport.SCALING_3D_MODE_BILINEAR
  7. @onready var viewport: Window = get_tree().root
  8. @onready var scale_label: Label = $VBoxContainer/Scale
  9. @onready var filter_label: Label = $VBoxContainer/Filter
  10. func _ready() -> void:
  11. viewport.scaling_3d_mode = filter_mode
  12. func _unhandled_input(event: InputEvent) -> void:
  13. if event.is_action_pressed(&"cycle_viewport_resolution"):
  14. scale_factor = wrapi(scale_factor + 1, 1, 5)
  15. viewport.scaling_3d_scale = 1.0 / scale_factor
  16. scale_label.text = "Scale: %3.0f%%" % (100.0 / scale_factor)
  17. if event.is_action_pressed(&"toggle_filtering"):
  18. filter_mode = wrapi(filter_mode + 1, Viewport.SCALING_3D_MODE_BILINEAR, Viewport.SCALING_3D_MODE_MAX) as Viewport.Scaling3DMode
  19. viewport.scaling_3d_mode = filter_mode
  20. filter_label.text = (
  21. ClassDB.class_get_enum_constants("Viewport", "Scaling3DMode")[filter_mode]
  22. .capitalize()
  23. .replace("3d", "3D")
  24. .replace("Mode", "Mode:")
  25. .replace("Fsr", "FSR")
  26. )