-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart.py
82 lines (61 loc) · 2.37 KB
/
chart.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
'''
Reads files which has information of chart
which includes:
(time offset in milliseconds, line number)
Update: hold node is included, then change to
node:
(node type, time offset in milliseconds, line number,points)
hold:
(node type, time offset in milliseconds, line number, points, length)
'''
import pygame
import os, sys
from chart_builder import *
def check_chart_exists(path):
if os.path.isfile(path):
return True
else:
return False
def get_chart_info(song_name):
APP_FOLDER = os.path.dirname(os.path.realpath(sys.argv[0]))+'/charts/'
full_path = os.path.join(APP_FOLDER, '%s.txt'%song_name)
if not check_chart_exists(full_path):
return 0,0,0,0,0
with open("%s"%full_path, "r") as f:
lines = f.readlines()
first_line = lines[0]
first_line.rstrip()
first_line = first_line.split(',')
song_length = int(first_line[0])
song_bpm = int(first_line[1]) # milli-seconds per beat
song_difficulty = int(first_line[2])
total_points = int(first_line[3])
recommended_fps = int(first_line[4])
return song_bpm, song_length, song_difficulty, total_points, recommended_fps
def get_chart(song_name):
APP_FOLDER = os.path.dirname(os.path.realpath(sys.argv[0]))+'/charts/'
full_path = os.path.join(APP_FOLDER, '%s.txt'%song_name)
if not check_chart_exists(full_path):
return 0,0,0,0,0,[]
request = []
with open("%s"%full_path, "r") as f:
lines = f.readlines()
first_line = lines[0]
first_line.rstrip()
first_line = first_line.split(',')
song_length = int(first_line[0])
song_bpm = int(first_line[1]) # milli-seconds per beat
song_difficulty = int(first_line[2])
total_points = int(first_line[3])
recommended_fps = int(first_line[4])
lines = lines[1:]
for line in lines:
line.rstrip()
data = line.split(',')
request.append(data) # just feed a raw information
print("Current song: %s"%song_name)
print("BPM: %d" %song_bpm)
print("Total Points: %d"%total_points)
print("Difficulty: %d"%song_difficulty)
print("Recommended_fps: %d"%recommended_fps)
return total_points, song_difficulty, song_length, song_bpm, recommended_fps, request