mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
Update tja2.py
This commit is contained in:
16
libs/tja2.py
16
libs/tja2.py
@@ -148,23 +148,22 @@ class TJAParser2(TJAParser):
|
|||||||
return registry
|
return registry
|
||||||
|
|
||||||
def handle_measure(self, part: str, state: ParserState):
|
def handle_measure(self, part: str, state: ParserState):
|
||||||
divisor = part.find('/')
|
numerator, denominator = part.split('/')
|
||||||
state.time_signature = float(part[9:divisor]) / float(part[divisor+1:])
|
state.time_signature = float(numerator) / float(denominator)
|
||||||
|
|
||||||
def handle_scroll(self, part: str, state: ParserState):
|
def handle_scroll(self, part: str, state: ParserState):
|
||||||
scroll_value = part[7:]
|
if 'i' in part:
|
||||||
if 'i' in scroll_value:
|
normalized = part.replace('.i', 'j').replace('i', 'j')
|
||||||
normalized = scroll_value.replace('.i', 'j').replace('i', 'j')
|
|
||||||
normalized = normalized.replace(',', '')
|
normalized = normalized.replace(',', '')
|
||||||
c = complex(normalized)
|
c = complex(normalized)
|
||||||
state.scroll_x_modifier = c.real
|
state.scroll_x_modifier = c.real
|
||||||
state.scroll_y_modifier = c.imag
|
state.scroll_y_modifier = c.imag
|
||||||
else:
|
else:
|
||||||
state.scroll_x_modifier = float(scroll_value)
|
state.scroll_x_modifier = float(part)
|
||||||
state.scroll_y_modifier = 0.0
|
state.scroll_y_modifier = 0.0
|
||||||
|
|
||||||
def handle_bpmchange(self, part: str, state: ParserState):
|
def handle_bpmchange(self, part: str, state: ParserState):
|
||||||
parsed_bpm = float(part[11:])
|
parsed_bpm = float(part)
|
||||||
if state.scroll_type == ScrollType.BMSCROLL or state.scroll_type == ScrollType.HBSCROLL:
|
if state.scroll_type == ScrollType.BMSCROLL or state.scroll_type == ScrollType.HBSCROLL:
|
||||||
# Do not modify bpm, it needs to be changed live by bpmchange
|
# Do not modify bpm, it needs to be changed live by bpmchange
|
||||||
bpmchange = parsed_bpm / state.bpmchange_last_bpm
|
bpmchange = parsed_bpm / state.bpmchange_last_bpm
|
||||||
@@ -252,7 +251,8 @@ class TJAParser2(TJAParser):
|
|||||||
if part.startswith('#'):
|
if part.startswith('#'):
|
||||||
for cmd_prefix, handler in commands.items():
|
for cmd_prefix, handler in commands.items():
|
||||||
if part.startswith(cmd_prefix):
|
if part.startswith(cmd_prefix):
|
||||||
handler(part, state)
|
value = part[len(cmd_prefix):].strip()
|
||||||
|
handler(value, state)
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
elif len(part) > 0 and not part[0].isdigit():
|
elif len(part) > 0 and not part[0].isdigit():
|
||||||
|
|||||||
Reference in New Issue
Block a user