-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.gd
More file actions
77 lines (56 loc) · 2.26 KB
/
Copy pathmain.gd
File metadata and controls
77 lines (56 loc) · 2.26 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
77
extends Control
@onready var file_manager = $MarginContainer/VBoxContainer/FileManager
@onready var learning = $MarginContainer/VBoxContainer/Learning
func _enter_tree() -> void:
UserSettings.load_settings()
func _ready():
$SaveTimer.wait_time = UserSettings.res.save_timer
get_tree().auto_accept_quit = false
for arg in OS.get_cmdline_args():
if arg.get_extension() == "mLab":
file_manager.open_file(arg)
#if on android this is required to be able to access files
if OS.has_feature("android"):
OS.request_permissions()
get_tree().root.content_scale_factor = 2.0
$MarginContainer/VBoxContainer/HBoxContainer/StatusText.hide()
$MarginContainer/VBoxContainer/HBoxContainer/SwitchModeButton.icon = preload("res://assets/images/Play.svg")
func _process(delta: float) -> void:
$MarginContainer/VBoxContainer/HBoxContainer/StatusText.text = gb.status_text
func _on_file_manager_files_changed():
print("files changed")
file_manager.autosave()
func _on_file_manager_files_edited() -> void:
print("files edited")
file_manager.autosave()
func _on_new_file_button_pressed():
await file_manager.new_file()
func _on_save_button_pressed():
gb.status("[color="+UserSettings.correct_hex+"]saved[/color]")
file_manager.save_all_files()
UserSettings.save_settings()
func _on_open_file_button_pressed():
await file_manager.open_files()
learning.combine_files(file_manager.opened_files)
func _on_switch_mode_button_pressed():
if file_manager.visible:
print("file manager")
file_manager.hide()
learning.show()
$MarginContainer/VBoxContainer/HBoxContainer/SwitchModeButton.text = "Files"
$MarginContainer/VBoxContainer/HBoxContainer/SwitchModeButton.icon = preload("res://assets/images/Pause.svg")
elif learning.visible:
print("learning")
learning.hide()
file_manager.show()
$MarginContainer/VBoxContainer/HBoxContainer/SwitchModeButton.text = "Learn"
$MarginContainer/VBoxContainer/HBoxContainer/SwitchModeButton.icon = preload("res://assets/images/Play.svg")
func _on_save_timer_timeout():
file_manager.autosave()
UserSettings.save_settings()
#called when the application is closed
func _notification(what: int) -> void:
if what == NOTIFICATION_WM_CLOSE_REQUEST:
file_manager.autosave()
UserSettings.save_settings()
get_tree().quit()