Simplify #SECTION
/#BRANCHSTART
logic
Previous code was unnecessarily convoluted.
This commit is contained in:
parent
f088e95e02
commit
ec72398abe
@ -196,16 +196,8 @@ def convert_tja_to_fumen(tja):
|
||||
if barline_off or is_submeasure:
|
||||
measure_fumen.barline = False
|
||||
|
||||
# If a #SECTION command occurs in isolation, and it has a valid
|
||||
# condition, then treat it like a branch_start
|
||||
if (measure_tja.section is not None
|
||||
and measure_tja.section != 'not_available'
|
||||
and not measure_tja.branch_start):
|
||||
branch_condition = measure_tja.section
|
||||
else:
|
||||
branch_condition = measure_tja.branch_start
|
||||
|
||||
# Check to see if the measure contains a branching condition
|
||||
branch_condition = measure_tja.branch_start
|
||||
if branch_condition:
|
||||
# Update the branch_info values for the measure
|
||||
measure_fumen.set_branch_info(
|
||||
|
@ -185,16 +185,18 @@ def parse_tja_course_data(course):
|
||||
elif line.name == 'MEASURE':
|
||||
current_event = TJAData('measure', line.value, pos)
|
||||
elif line.name == 'SECTION':
|
||||
if branch_condition is None:
|
||||
current_event = TJAData('section', 'not_available', pos)
|
||||
else:
|
||||
current_event = TJAData('section', branch_condition, pos)
|
||||
# If the command immediately after #SECTION is #BRANCHSTART,
|
||||
# then we need to make sure that #SECTION is put on every
|
||||
# branch. (We can't do this unconditionally because #SECTION
|
||||
# commands can also exist in isolation.)
|
||||
# If #SECTION occurs before a #BRANCHSTART, then ensure that
|
||||
# it's present on every branch. Otherwise, #SECTION will only
|
||||
# be present on the current branch, and so the `branch_info`
|
||||
# values won't be correctly set for the other two branches.
|
||||
if course.data[idx_l+1].name == 'BRANCHSTART':
|
||||
current_event = TJAData('section', None, pos)
|
||||
current_branch = 'all'
|
||||
# Otherwise, #SECTION exists in isolation. In this case, to
|
||||
# reset the accuracy, we just repeat the previous #BRANCHSTART.
|
||||
else:
|
||||
current_event = TJAData('branch_start', branch_condition,
|
||||
pos)
|
||||
elif line.name == 'BRANCHSTART':
|
||||
if flag_levelhold:
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user