-
Notifications
You must be signed in to change notification settings - Fork 0
/
v2tov3.py
97 lines (92 loc) · 2.63 KB
/
v2tov3.py
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
import json
def convert(map):
notes=map["_notes"]
#sliders obstacles bombs and waypoints are not supported at this time
newNotes=[]
bombs=[]
for i in notes:
note={
"b": i["_time"],
"x": i["_lineIndex"],
"y": i["_lineLayer"],
"c": 0,
"a": 0,
"d": i["_cutDirection"]
}
if i["_type"]==0:
note["c"]=0
elif i["_type"]==1:
note["c"]=1
elif i["_type"]==3:
bombs.append({
"b":i["_time"],
"x": i["_lineIndex"],
"y": i["_lineLayer"]
})
continue
else:
continue
if "_customData" in i:
if "_fake" in i["_customData"]:
if i["_customData"]["_fake"]:
continue
newNotes.append(note)
oldObstacles=map["_obstacles"]
obstacles=[]
for i in oldObstacles:
ob={
"b": i["_time"],
"x": i["_lineIndex"],
"y": 0 if["_type"]==0 else 2,
"d": i["_duration"],
"w": i["_width"],
"h": 5 - (0 if["_type"]==0 else 2)
}
obstacles.append(ob)
lights=[]
for i in map["_events"]:
li={
"b": i["_time"],
"et": i["_type"],
"i": i["_value"],
"f": 1
}
try:
li["f"]= i["_floatValue"]
except:
pass
lights.append(li)
newMap={
"version":"3.0.0",
"bpmEvents": [],
"rotationEvents": [],
"colorNotes": newNotes,
"bombNotes": bombs,
"obstacles": obstacles,
"sliders": [],
"burstSliders": [],
"waypoints": [],
"basicBeatmapEvents": lights,
"colorBoostBeatmapEvents": [],
"lightColorEventBoxGroups": [],
"lightRotationEventBoxGroups": [],
"basicEventTypesWithKeywords": {},
"useNormalEventsAsCompatibleEvents": False
}
return newMap
if __name__=="__main__":
with open("beatmap/Info.dat","r") as f:
info = json.load(f)
beatmaps=info["_difficultyBeatmapSets"][0]["_difficultyBeatmaps"]
for i in beatmaps:
print(i["_beatmapFilename"])
with open("beatmap/"+i["_beatmapFilename"],"r") as f:
print("beatmap/"+i["_beatmapFilename"])
try:
map=json.load(f)
except:
continue
with open("beatmap/"+i["_beatmapFilename"],"w") as f:
#print(convert(map))
json.dump(convert(map),f,separators=(',', ':'))
print("done")