7 # Required information for a loader module. If this isn't here, the game
8 # will crash and burn and it will be ALL YOUR FAULT.
13 res = [re.compile("^#SUBTITLE"), re.compile("^#BANNER"),
14 re.compile("^#BACKGROUND"),re.compile("^#NOTES")]
19 for n in range(0,len(res)):
20 if res[n].match(line):
22 return sum(match) / float(len(match))
27 def load(file,status=lambda x,y:None):
28 keymapping = {0:1, 1:2, 2:3, 3:4, 4:5, 5:0, 7:6, 8:7}
30 kf.numkeys = len(keymapping)
31 dir = os.path.dirname(file)
34 matcher = re.compile("#([A-Z]+):(.*);",re.DOTALL)
38 line = line.split('//')[0];
43 m = matcher.match(buf)
47 arg = m.group(2).split(':')
53 elif cmd == "SUBTITLE":
58 bpmlist = map(lambda x: x.split('='),arg[0].split(','))
59 kf.bpm = bpmlist[0][1]
61 kf.add(BMEvent(float(b[0]), BME_TEMPO, None, float(b[1])))
64 stoplist = map(lambda x: x.split('='),arg[0].split(','))
67 kf.add(BMEvent(float(s[0]), BME_STOP, None, int(float(s[1])*1000)))
68 elif cmd == "BACKGROUND":
71 kf.stagefile = pygame.image.load(os.path.join(dir,arg[0]))
72 kf.stagefile = kf.stagefile.convert()
73 status("STAGEFILE",kf.stagefile)
77 kf.offset = float(arg[0])
78 kf.add(BMEvent(int(kf.offset * 1000), BME_BGM, None, 255))
80 print os.path.join(dir,arg[0])
82 pygame.mixer.music.load(os.path.join(dir,arg[0]))
84 pygame.mixer.music.load(os.path.join(dir,arg[0].lower()))
85 kf.wavs[255] = pygame.mixer.music
87 if arg[0] == 'dance-single' and arg[2].lower() == 'challenge':
88 parse_notes(arg[5],kf)
90 print "Unknown command:",cmd
96 # BUGS! This assumes a four-column chart.
97 def parse_notes(str,kf):
98 tracks = str.split(',')
106 if k == 'M': # Freaking mines...
110 beat = 4 * (track + (float(n)/l))
111 # Add note filter here?
112 kf.add(BMEvent(beat, BME_NOTE1, m*2+1, 1))