From 6da094d837b1d3b90d1045d2181f277aff1b2f0d Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 7 Feb 2021 00:17:27 +1030 Subject: [PATCH] Fix some regressions in the SRT code and Video player --- singletons/FileLoader.gd | 29 +++++++++++++++++++++-------- singletons/Note.gd | 15 ++++++++++++--- singletons/Settings.gd | 15 +++++++++++++++ singletons/Video.gd | 1 + 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/singletons/FileLoader.gd b/singletons/FileLoader.gd index 0a12229..d088624 100644 --- a/singletons/FileLoader.gd +++ b/singletons/FileLoader.gd @@ -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) diff --git a/singletons/Note.gd b/singletons/Note.gd index 815d407..e0f9351 100644 --- a/singletons/Note.gd +++ b/singletons/Note.gd @@ -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: diff --git a/singletons/Settings.gd b/singletons/Settings.gd index 4e5899a..9c5de6c 100644 --- a/singletons/Settings.gd +++ b/singletons/Settings.gd @@ -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 diff --git a/singletons/Video.gd b/singletons/Video.gd index 14272f6..0d6abc3 100644 --- a/singletons/Video.gd +++ b/singletons/Video.gd @@ -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)