This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/Menu.gd

43 lines
1 KiB
GDScript3
Raw Permalink Normal View History

2020-07-10 13:37:13 +00:00
extends Control
2020-07-10 13:20:56 +00:00
export var scale = 2 setget set_scale
export var upThreshold = 1.0/Engine.iterations_per_second
export var downThreshold = 1.0/30.0
export var delay = 1.0
2020-07-10 13:37:13 +00:00
func _ready():
2020-07-10 13:20:56 +00:00
set_scale(scale)
2020-07-10 13:37:13 +00:00
$"/root/Music/BGM".play()
2020-07-10 13:20:56 +00:00
func _process(delta):
# Give the system time to adjust
if delay > 0:
delay -= delta
return
if delta > downThreshold:
print("GPU is taking too much (", delta, "s < ", downThreshold, "s), adjusting shader scale")
set_scale(scale+1)
2020-07-12 15:26:40 +00:00
elif delta < upThreshold and scale > 2:
2020-07-10 13:20:56 +00:00
print("GPU is taking it easy (", delta, "s < ", upThreshold, "s), adjusting shader scale")
set_scale(scale-1)
func set_scale(val):
scale = val
$Viewport.size = rect_size / scale
$Background.update()
func _on_resized():
$Viewport.size = rect_size / scale
$Background.update()
2020-07-12 15:26:40 +00:00
func _host_pressed():
$"/root/Music/BGM".stop()
$"/root/Multiplayer".host()
func _join_pressed():
pass
func _server_addr_changed(new_text: String):
$CenterContainer/PanelContainer/HBoxContainer/JoinButton.disabled = new_text.length() < 1