Improve chart difficulty selection resilience
This commit is contained in:
parent
82280ca49d
commit
d1e3150061
|
@ -590,7 +590,7 @@ func load_folder(folder, filename='song'):
|
||||||
|
|
||||||
func load_filelist(filelist: Array, directory=''):
|
func load_filelist(filelist: Array, directory=''):
|
||||||
var charts = {}
|
var charts = {}
|
||||||
var key := 1
|
var key := 0
|
||||||
for name in filelist:
|
for name in filelist:
|
||||||
var extension: String = name.rsplit('.', true, 1)[-1]
|
var extension: String = name.rsplit('.', true, 1)[-1]
|
||||||
name = directory.rstrip('/') + '/' + name
|
name = directory.rstrip('/') + '/' + name
|
||||||
|
@ -600,8 +600,8 @@ func load_filelist(filelist: Array, directory=''):
|
||||||
'rgtm': # multiple charts
|
'rgtm': # multiple charts
|
||||||
var res = RGT.load_file(filename)
|
var res = RGT.load_file(filename)
|
||||||
for k in res:
|
for k in res:
|
||||||
charts[k] = res[k]
|
charts[Library.difficulty_translations.get(k, k)] = res[k]
|
||||||
'rgts', 'rgtx': # single chart
|
'rgts', 'rgtx': # single chart - The keys for this should be translated afterwards
|
||||||
charts[key] = RGT.load_file(filename)
|
charts[key] = RGT.load_file(filename)
|
||||||
key += 1
|
key += 1
|
||||||
'srt': # maimai, single chart
|
'srt': # maimai, single chart
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
const difficulty_translations = {'01': 'Z', '02': 'B', '03': 'A', '04': 'E', '05': 'M', '06': 'R', '10': '宴'} # A bit redundant now but might be useful later for other hacks
|
||||||
|
|
||||||
class MultilangStr:
|
class MultilangStr:
|
||||||
# Automatically propogate higher langs to lower ones if lower ones are missing.
|
# Automatically propogate higher langs to lower ones if lower ones are missing.
|
||||||
# e.g. if we don't have a proper english title, return the transliterated one instead
|
# e.g. if we don't have a proper english title, return the transliterated one instead
|
||||||
|
@ -48,7 +50,7 @@ class Song:
|
||||||
var video_offsets: Array
|
var video_offsets: Array
|
||||||
var audio_preview_times: Array
|
var audio_preview_times: Array
|
||||||
var video_dimensions: Array
|
var video_dimensions: Array
|
||||||
var chart_difficulties: Dictionary
|
var chart_difficulties := {}
|
||||||
const default_difficulty_keys = ['Z', 'B', 'A', 'E', 'M', 'R', '宴']
|
const default_difficulty_keys = ['Z', 'B', 'A', 'E', 'M', 'R', '宴']
|
||||||
const difficulty_key_ids = {'Z':0, 'B':1, 'A':2, 'E':3, 'M':4, 'R':5, '宴':6}
|
const difficulty_key_ids = {'Z':0, 'B':1, 'A':2, 'E':3, 'M':4, 'R':5, '宴':6}
|
||||||
|
|
||||||
|
@ -83,12 +85,10 @@ class Song:
|
||||||
TYPE_DICTIONARY:
|
TYPE_DICTIONARY:
|
||||||
chart_difficulties = diffs
|
chart_difficulties = diffs
|
||||||
TYPE_ARRAY:
|
TYPE_ARRAY:
|
||||||
chart_difficulties = {}
|
|
||||||
for i in min(len(diffs), len(default_difficulty_keys)):
|
for i in min(len(diffs), len(default_difficulty_keys)):
|
||||||
chart_difficulties[default_difficulty_keys[i]] = diffs[i]
|
chart_difficulties[default_difficulty_keys[i]] = diffs[i]
|
||||||
_:
|
_:
|
||||||
print_debug('Invalid chart_difficulties!', title.en)
|
print_debug('Invalid chart_difficulties!', title.en)
|
||||||
chart_difficulties = {}
|
|
||||||
|
|
||||||
func get_BPM(realtime:=0.0):
|
func get_BPM(realtime:=0.0):
|
||||||
if not dynamic_bpm:
|
if not dynamic_bpm:
|
||||||
|
@ -128,7 +128,23 @@ func get_song_charts(song_key):
|
||||||
if song_key in charts_cache:
|
if song_key in charts_cache:
|
||||||
return charts_cache[song_key]
|
return charts_cache[song_key]
|
||||||
elif song_key in all_songs:
|
elif song_key in all_songs:
|
||||||
charts_cache[song_key] = FileLoader.load_filelist(all_songs[song_key].chart_filelist, 'songs/'+all_songs[song_key].filepath)
|
var charts = FileLoader.load_filelist(all_songs[song_key].chart_filelist, 'songs/'+all_songs[song_key].filepath)
|
||||||
|
# Need to fix keys on this to match the song
|
||||||
|
var diffs = all_songs[song_key].chart_difficulties
|
||||||
|
var missing_diffs = []
|
||||||
|
var unid_charts = []
|
||||||
|
for k in diffs:
|
||||||
|
if not (k in charts):
|
||||||
|
missing_diffs.push_back(k)
|
||||||
|
for k in charts:
|
||||||
|
if not (k in diffs):
|
||||||
|
unid_charts.push_back(k)
|
||||||
|
for i in len(missing_diffs):
|
||||||
|
if i < len(unid_charts):
|
||||||
|
charts[missing_diffs[i]] = charts[unid_charts[i]]
|
||||||
|
charts.erase(unid_charts[i])
|
||||||
|
|
||||||
|
charts_cache[song_key] = charts
|
||||||
return charts_cache[song_key]
|
return charts_cache[song_key]
|
||||||
else:
|
else:
|
||||||
print_debug('Invalid song_key: ', song_key)
|
print_debug('Invalid song_key: ', song_key)
|
||||||
|
|
|
@ -92,7 +92,7 @@ func _process(delta):
|
||||||
if (menu_mode == MenuMode.GAMEPLAY) and (menu_mode_prev_fade_timer <= 0.0) and not NoteHandler.running:
|
if (menu_mode == MenuMode.GAMEPLAY) and (menu_mode_prev_fade_timer <= 0.0) and not NoteHandler.running:
|
||||||
var songslist = genres[genres.keys()[selected_genre]]
|
var songslist = genres[genres.keys()[selected_genre]]
|
||||||
var song_key = songslist[selected_song % len(songslist)]
|
var song_key = songslist[selected_song % len(songslist)]
|
||||||
NoteHandler.load_track(song_key, selected_difficulty)
|
NoteHandler.load_track(song_key, Library.Song.default_difficulty_keys[selected_difficulty])
|
||||||
NoteHandler.running = true
|
NoteHandler.running = true
|
||||||
|
|
||||||
func draw_string_centered(font, position, string, color := Color.white):
|
func draw_string_centered(font, position, string, color := Color.white):
|
||||||
|
|
|
@ -512,14 +512,14 @@ func _ready():
|
||||||
InputHandler.connect('button_released', self, 'button_released')
|
InputHandler.connect('button_released', self, 'button_released')
|
||||||
InputHandler.connect('touchbutton_released', self, 'touchbutton_released')
|
InputHandler.connect('touchbutton_released', self, 'touchbutton_released')
|
||||||
|
|
||||||
func load_track(song_key: String, difficulty_idx: int):
|
func load_track(song_key: String, difficulty_key: String):
|
||||||
self.song_key = song_key
|
self.song_key = song_key
|
||||||
set_time(-3.0)
|
set_time(-3.0)
|
||||||
active_notes = []
|
active_notes = []
|
||||||
next_note_to_load = 0
|
next_note_to_load = 0
|
||||||
all_notes = []
|
all_notes = []
|
||||||
var data = Library.all_songs[song_key]
|
var data = Library.all_songs[song_key]
|
||||||
var chart = Library.get_song_charts(song_key).values()[difficulty_idx]
|
var chart = Library.get_song_charts(song_key)[difficulty_key]
|
||||||
for note in chart[1]:
|
for note in chart[1]:
|
||||||
all_notes.append(Note.copy_note(note))
|
all_notes.append(Note.copy_note(note))
|
||||||
bpm = data.BPM
|
bpm = data.BPM
|
||||||
|
|
Loading…
Reference in New Issue