-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.gd
More file actions
39 lines (37 loc) · 2.16 KB
/
editor.gd
File metadata and controls
39 lines (37 loc) · 2.16 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
extends AspectRatioContainer
@onready var music = $Music
@onready var progress = $PanelContainer/VBoxContainer/PanelContainer/Operations/Progress
@onready var scroll = $PanelContainer/VBoxContainer/Control/AspectRatioContainer/ScrollContainer
@onready var interval = $PanelContainer/VBoxContainer/Control/HBoxContainer/Operations/ScrollContainer/MarginContainer/VBoxContainer/Interval
func _ready() -> void:
_on_resized()
var fa = FileAccess.open(Global.DIR + Global.SEPARATOR + Global.path + Global.SEPARATOR + Global.path + ".json", FileAccess.READ)
Global.loaded = JSON.parse_string(fa.get_as_text())
fa.close()
fa = FileAccess.open(Global.DIR + Global.SEPARATOR + Global.path + "/info.json", FileAccess.READ)
var info = JSON.parse_string(fa.get_as_text())
match info["music"].get_extension():
"mp3":
music.stream = AudioStreamMP3.load_from_file(Global.DIR + Global.SEPARATOR + Global.path + Global.SEPARATOR + info["music"])
"ogg":
music.stream = AudioStreamOggVorbis.load_from_file(Global.DIR + Global.SEPARATOR + Global.path + Global.SEPARATOR + info["music"])
"wav":
music.stream = AudioStreamWAV.load_from_file(Global.DIR + Global.SEPARATOR + Global.path + Global.SEPARATOR + info["music"])
$AspectRatioContainer/Illustration.texture = ImageTexture.create_from_image(Image.load_from_file(Global.DIR + Global.SEPARATOR + Global.path + Global.SEPARATOR + info["illustration"]))
fa.close()
progress.max_value = music.stream.get_length()
Global.length = music.stream.get_length()
refresh_h_lines(4)
scroll.scroll_vertical = scroll.get_v_scroll_bar().max_value
func _process(_delta: float) -> void:
if music.playing:
scroll.scroll_vertical = scroll.get_v_scroll_bar().max_value - progress.value * interval.value
func _on_resized() -> void:
ratio = size.x / size.y
func refresh_h_lines(h_lines: int = 0) -> void:
var note = $PanelContainer/VBoxContainer/Control/AspectRatioContainer/ScrollContainer/HBoxContainer/Note
var event = $PanelContainer/VBoxContainer/Control/AspectRatioContainer/ScrollContainer/HBoxContainer/Event
for i in note.size.y * 2:
for j in h_lines:
var color = ColorRect.new()
color.color = Color(255, 0, 0) if j == 0 else Color(0, 255, 0)