Skip to content

Commit 57f6dc8

Browse files
committed
Added Beautify and changed noting pattern
1 parent 136003e commit 57f6dc8

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
/__pycache__
33
main.py
44
*.zip
5-
3q4a.sprd
6-
example.ogg
5+
/debug

compiler.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pyrd import *
22
from utils import *
3-
3+
import re
44
FUNCTION_DICT={
55
"播放音乐":PlayMusic,
66
"七拍":AddClassicBeat,
@@ -56,18 +56,20 @@ def parseBar(bar:str,barNum):
5656

5757
content = []
5858
#fileName = input("请输入sprd文件名:")
59-
fileName = "3q4a.sprd"
59+
fileName = "debug/1.sprd"
6060
with open(fileName,'r',encoding="utf-8") as f:
6161
sprd = f.read()
6262
content = sprd.split("```")
6363
metadata = content[0].split('\n')
6464
metadata = [x.strip() for x in metadata if x.strip()!=""]
6565
character = content[1].split('\n')
6666
character = [x.strip() for x in character if x.strip()!=""]
67-
bars = content[2:]
68-
bars = [x.strip() for x in bars if x.strip()!=""]
67+
bar = content[2]
68+
pattern = re.compile(r'\[(\d+)\](?>\n)(.*?)(?=\[|$)', re.S)
69+
result = re.findall(pattern, bar)
6970
parseMetaData(metadata)
7071
parseCharacter(character)
71-
for i in range(len(bars)):
72-
parseBar(bars[i],i+1)
72+
for bar in result:
73+
barNum,barContent = bar
74+
parseBar(barContent.strip(),int(barNum))
7375
Export()

pyrd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ def FreeBeat_Pulse(bar,beat,row,action,customPulse):
150150
def Export():
151151
fileName=level["settings"]["artist"]+"-"+level["settings"]["song"]+".rdlevel"
152152
with open(fileName,"w",encoding="utf-8")as f:
153-
f.write(json.dumps(level))
153+
f.write(json.dumps(level,sort_keys=True, indent=2).encode('utf-8').decode("unicode_escape"))
154154

0 commit comments

Comments
 (0)