-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.gd
More file actions
140 lines (138 loc) · 3.2 KB
/
global.gd
File metadata and controls
140 lines (138 loc) · 3.2 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
extends Node
var DIR: String
var SEPARATOR: String
var artist: String
var author: String
var chart: String
var illustration: String
var illustrator: String
var music: String
var path: String
var version: String
var type: int = 0
var mode: int = 0
var length: float
var pathes: PackedStringArray = PackedStringArray()
var loaded: Dictionary
func _ready() -> void:
match OS.get_name():
"Android":
SEPARATOR = "/"
DIR = "/storage/emulated/0/Android/data/com.dzh.phiator/files"
"Windows":
SEPARATOR = "\\"
DIR = OS.get_data_dir()
if OS.is_debug_build() and not OS.has_feature("template"):
DIR = "/storage/emulated/0/Android/data/org.godotengine.editor.v4/files/" + ProjectSettings.get_setting("application/config/name")
func create_chart() -> void:
var r = FileAccess.open(music, FileAccess.READ)
var fa = FileAccess.open(DIR + SEPARATOR + path + SEPARATOR + music.get_file(), FileAccess.WRITE)
fa.store_buffer(r.get_buffer(r.get_length()))
fa.close()
r.close()
r = FileAccess.open(illustration, FileAccess.READ)
fa = FileAccess.open(DIR + SEPARATOR + path + SEPARATOR + illustration.get_file(), FileAccess.WRITE)
fa.store_buffer(r.get_buffer(r.get_length()))
fa.close()
r.close()
fa = FileAccess.open(DIR + SEPARATOR + path + "/info.json", FileAccess.WRITE)
fa.store_string(JSON.stringify(
{
"artist": artist,
"author": author,
"chart": chart,
"illustration": illustration.get_file(),
"illustrator": illustrator,
"music": music.get_file(),
"offset": 0,
"path": path,
"version": version
}
))
fa.close()
fa = FileAccess.open(DIR + SEPARATOR + path + SEPARATOR + path + ".json", FileAccess.WRITE)
fa.store_string(JSON.stringify(
{
"bpm": [
{
"beat": [ 0, 0, 1 ],
"bpm": 120
}
],
"line": [
{
"eventLayer": [
{
"alpha": [
{
"beat": [
[ 0, 0, 1 ],
[ 1, 0, 1 ]
],
"easing": 1,
"value": [ 0, 0 ]
}
],
"moveX": [
{
"beat": [
[ 0, 0, 1 ],
[ 1, 0, 1 ]
],
"easing": 1,
"value": [ 0, 0 ]
}
],
"moveY": [
{
"beat": [
[ 0, 0, 1 ],
[ 1, 0, 1 ]
],
"easing": 1,
"value": [ 0, 0 ]
}
],
"rotate": [
{
"beat": [
[ 0, 0, 1 ],
[ 1, 0, 1 ]
],
"easing": 1,
"value": [ 0, 0 ]
}
],
"speed": [
{
"beat": [
[ 0, 0, 1 ],
[ 1, 0, 1 ]
],
"value": [ 10, 10 ]
}
]
}
],
"note": []
}
]
}
))
fa.close()
func import_chart(_path: String) -> void:
pass
func export_chart(rpe: bool, p: String) -> void:
var fa = FileAccess.open(DIR + SEPARATOR + path + SEPARATOR + path + ".json", FileAccess.READ)
var c = JSON.parse_string(fa.get_as_text())
fa.close()
var result = {
} if rpe else c
fa = FileAccess.open(p, FileAccess.WRITE)
fa.store_string(JSON.stringify(result))
fa.close()
func delete_chart() -> void:
var d = DirAccess.open(DIR + SEPARATOR + path)
for f in d.get_files():
d.remove(f)
DirAccess.remove_absolute(DIR + SEPARATOR + path)