-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart_list.gd
More file actions
26 lines (25 loc) · 1.35 KB
/
chart_list.gd
File metadata and controls
26 lines (25 loc) · 1.35 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
extends VBoxContainer
var dir: DirAccess
func _ready() -> void:
#while !OS.request_permission("android.permission.MANAGE_EXTERNAL_STORAGE") if OS.get_version().substr(0, OS.get_version().find(".")).to_int() > 29 else !OS.request_permission("android.permission.READ_EXTERNAL_STORAGE") and !OS.request_permission("android.permission.WRITE_EXTERNAL_STORAGE"):
#pass
DirAccess.make_dir_recursive_absolute(Global.DIR)
dir = DirAccess.open(Global.DIR)
refresh()
func _process(_delta: float) -> void:
pass
func refresh() -> void:
Global.pathes.clear()
for i in get_child_count():
remove_child(get_child(0))
for d in dir.get_directories():
for f in DirAccess.open(Global.DIR + Global.SEPARATOR + d).get_files():
if f.to_lower() == "info.json":
var chart = preload("res://chart.tscn").instantiate()
var fa = FileAccess.open(Global.DIR + Global.SEPARATOR + d + "/info.json", FileAccess.READ)
var info = JSON.parse_string(fa.get_as_text())
chart.get_child(0).texture = ImageTexture.create_from_image(Image.load_from_file(Global.DIR + Global.SEPARATOR + d + Global.SEPARATOR + info["illustration"]))
chart.get_child(1).get_child(0).text = info["chart"]
chart.get_child(1).get_child(1).text = "曲师:" + info["artist"] + "\n版本:" + info["version"] + "\n谱师:" + info["author"]
Global.pathes.append(info["path"])
add_child(chart)