Fix some regressions in the SRT code and Video player
This commit is contained in:
parent
b74c2c7df5
commit
6da094d837
|
@ -167,13 +167,17 @@ class SRT:
|
|||
if err != OK:
|
||||
print(err)
|
||||
return err
|
||||
var notes = []
|
||||
var metadata := {}
|
||||
var num_taps := 0
|
||||
var num_holds := 0
|
||||
var num_slides := 0
|
||||
var notes := []
|
||||
var beats_per_measure := 4
|
||||
var length = file.get_len()
|
||||
var slide_ids = {}
|
||||
while (file.get_position() < (length-2)):
|
||||
var noteline = file.get_csv_line()
|
||||
var time_hit := (float(noteline[0]) + (float(noteline[1]))-1.0) * beats_per_measure
|
||||
var time_hit := (float(noteline[0]) + (float(noteline[1]))) * beats_per_measure
|
||||
var duration := float(noteline[2]) * beats_per_measure
|
||||
var column := int(noteline[3])
|
||||
var id := int(noteline[4])
|
||||
|
@ -183,8 +187,10 @@ class SRT:
|
|||
match id:
|
||||
ID_HOLD:
|
||||
notes.push_back(Note.NoteHold.new(time_hit, column, duration))
|
||||
num_holds += 1
|
||||
ID_BREAK:
|
||||
notes.push_back(Note.NoteTap.new(time_hit, column, true))
|
||||
num_taps += 1
|
||||
ID_SLIDE_END:
|
||||
# id2 is slide ID
|
||||
if id2 in slide_ids:
|
||||
|
@ -193,6 +199,7 @@ class SRT:
|
|||
_:
|
||||
if id2 == 0:
|
||||
notes.push_back(Note.NoteTap.new(time_hit, column))
|
||||
num_taps += 1
|
||||
else:
|
||||
# id2 is slide ID, id3 is slide pattern
|
||||
# In order to properly declare the slide, we need the paired endcap which may not be the next note
|
||||
|
@ -207,12 +214,16 @@ class SRT:
|
|||
_:
|
||||
print('Unknown slide type: ', id3)
|
||||
var note = Note.NoteStar.new(time_hit, column)
|
||||
num_slides += 1
|
||||
note.duration = duration
|
||||
notes.push_back(note)
|
||||
var slide = Note.NoteSlide.new(time_hit, column, duration, -1, slide_type)
|
||||
notes.push_back(slide)
|
||||
slide_ids[id2] = slide
|
||||
return notes
|
||||
metadata['num_taps'] = num_taps
|
||||
metadata['num_holds'] = num_holds
|
||||
metadata['num_slides'] = num_slides
|
||||
return [metadata, notes]
|
||||
|
||||
|
||||
class RGT:
|
||||
|
@ -280,11 +291,11 @@ class RGT:
|
|||
|
||||
match format:
|
||||
Format.RGTS:
|
||||
var notes = parse_rgts(lines[0])
|
||||
return notes
|
||||
var metadata_and_notes = parse_rgts(lines[0])
|
||||
return metadata_and_notes
|
||||
Format.RGTX:
|
||||
var notes = parse_rgtx(lines[0])
|
||||
return notes
|
||||
var metadata_and_notes = parse_rgtx(lines[0])
|
||||
return metadata_and_notes
|
||||
Format.RGTM:
|
||||
lines.pop_front() # Anything before the first [header] is meaningless
|
||||
var charts = {}
|
||||
|
@ -631,7 +642,9 @@ func load_filelist(filelist: Array, directory=''):
|
|||
charts[key] = RGT.load_file(filename)
|
||||
key += 1
|
||||
'srt': # maimai, single chart
|
||||
charts[key] = SRT.load_file(filename)
|
||||
var metadata_and_notes = SRT.load_file(filename)
|
||||
Note.process_note_list(metadata_and_notes[1]) # SRT doesn't handle doubles
|
||||
charts[key] = metadata_and_notes
|
||||
key += 1
|
||||
'sm': # Stepmania, multiple charts
|
||||
var res = SM.load_file(filename)
|
||||
|
|
|
@ -242,9 +242,18 @@ static func process_note_list(note_array: Array, check_doubles:=true):
|
|||
# Doubles
|
||||
if check_doubles:
|
||||
for i in len(note_array)-1:
|
||||
if note_array[i].time_hit == note_array[i+1].time_hit:
|
||||
note_array[i].double_hit = true
|
||||
note_array[i+1].double_hit = true
|
||||
var note1 = note_array[i]
|
||||
if not note1.hittable:
|
||||
continue
|
||||
for j in len(note_array)-1-i:
|
||||
var note2 = note_array[i+j+1]
|
||||
if not note2.hittable:
|
||||
continue
|
||||
if note1.time_hit == note2.time_hit:
|
||||
note1.double_hit = true
|
||||
note2.double_hit = true
|
||||
else:
|
||||
break
|
||||
# Slides
|
||||
for i in len(note_array):
|
||||
if note_array[i].type == NOTE_SLIDE:
|
||||
|
|
|
@ -25,3 +25,18 @@ func SSY_get() -> float:
|
|||
return ProjectSettings.get_setting('rendering/quality/subsampling/y')
|
||||
func SSXY_get() -> Vector2:
|
||||
return Vector2(self.subsampling_x, self.subsampling_y)
|
||||
|
||||
|
||||
|
||||
const SETTINGS_FILENAME = 'user://settings.conf'
|
||||
|
||||
func load_settings():
|
||||
var config := ConfigFile.new()
|
||||
match config.load(SETTINGS_FILENAME):
|
||||
OK:
|
||||
pass
|
||||
ERR_FILE_NOT_FOUND:
|
||||
save_settings()
|
||||
|
||||
func save_settings():
|
||||
pass
|
||||
|
|
|
@ -12,6 +12,7 @@ func _ready():
|
|||
video.expand = false
|
||||
add_child(video) # Needs to be in scene tree to make the textures
|
||||
video.visible = false # Luckily this is enough to make the textures without rendering
|
||||
video.volume = 0.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
get_tree().call_group('VideoTexRects', 'set_texture', self.texture)
|
||||
|
|
Loading…
Reference in New Issue