-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.gd
More file actions
76 lines (56 loc) · 2.07 KB
/
main.gd
File metadata and controls
76 lines (56 loc) · 2.07 KB
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
68
69
70
71
72
73
74
75
76
extends Control
@export var installer: Installer
@export var dry_run: bool
@onready var dialog := %Dialog as Dialog
@onready var progress_dialog := %ProgressDialog as ProgressDialog
@onready var disk_menu := %DiskSelectMenu
@onready var install_menu := %InstallProgressMenu
@onready var logo := %Logo as TextureRect
var install_state := load("res://core/ui/menus/install_progress_state.tres") as State
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Allow the installer to add Godot nodes to the scene tree
installer.child_added.connect(_on_child_added)
installer.child_removed.connect(_on_child_removed)
installer.dry_run = dry_run
# Configure the interface for the installer
var config := installer.get_configuration()
if config:
if config.logo:
logo.texture = config.logo
if config.theme:
self.theme = config.theme
# Create the install options
if not install_state.has_meta("options"):
install_state.set_meta("options", Installer.Options.new())
# Set the installer logic to use
disk_menu.set_installer(installer)
install_menu.set_installer(installer, dry_run)
# Run the installer
run()
## Run the installer
func run():
if not DirAccess.dir_exists_absolute("/sys/firmware/efi/efivars"):
var msg := "Legacy BIOS installs are not supported. You must boot the installer in UEFI mode.\n\n" + \
"Would you like to restart the computer now?"
dialog.open(msg, "Yes", "No")
var should_reboot := await dialog.choice_selected as bool
if should_reboot:
OS.execute("reboot", [])
return
get_tree().quit(1)
return
if installer.get_available_disks().size() == 0:
var msg := "No available disks were detected. Unable to proceed with installation.\n\n" + \
"Would you like to restart the computer now?"
dialog.open(msg, "OK", "Cancel")
var should_reboot := await dialog.choice_selected as bool
if should_reboot:
OS.execute("reboot", [])
return
get_tree().quit(1)
return
func _on_child_added(node: Node) -> void:
add_child(node)
func _on_child_removed(node: Node) -> void:
remove_child(node)