-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmain.gd
68 lines (47 loc) · 1.7 KB
/
main.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
extends Node
const Settings = preload("res://settings.gd")
@onready var _main_menu : Control = $MainMenu
@onready var _settings_ui : Control = $SettingsUI
var _settings := Settings.new()
var _game : SolarSystem
func _ready():
_settings_ui.set_settings(_settings)
func _on_MainMenu_start_requested():
assert(_game == null)
_main_menu.hide()
var game_scene : PackedScene = load("res://game.tscn")
_game = game_scene.instantiate()
_game.set_settings(_settings)
_game.set_settings_ui(_settings_ui)
_game.exit_to_menu_requested.connect(_on_game_exit_to_menu_requested)
add_child(_game)
func _on_MainMenu_settings_requested():
_settings_ui.show()
func _on_MainMenu_exit_requested():
get_tree().quit()
func _on_game_exit_to_menu_requested():
_game.queue_free()
_game = null
_main_menu.show()
func _process(delta):
AudioServer.set_bus_volume_db(0, linear_to_db(_settings.main_volume_linear))
DDD.visible = _settings.debug_text
var viewport := get_viewport()
if _settings.wireframe != (viewport.debug_draw == Viewport.DEBUG_DRAW_WIREFRAME):
if _settings.wireframe:
viewport.debug_draw = Viewport.DEBUG_DRAW_WIREFRAME
else:
viewport.debug_draw = Viewport.DEBUG_DRAW_DISABLED
print("Setting viewport draw mode to ", viewport.debug_draw)
if _settings.antialias == Settings.ANTIALIAS_DISABLED:
viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED
elif _settings.antialias == Settings.ANTIALIAS_FXAA:
viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_FXAA
func _unhandled_input(event: InputEvent):
if _game != null:
# Let the game handle it
return
if event is InputEventKey:
if event.pressed and not event.is_echo():
if event.keycode == KEY_ESCAPE:
_settings_ui.hide()