Playable state with collections.

This commit is contained in:
Luke Hubmayer-Werner 2020-05-03 01:47:55 +09:30
parent e3b3dfc9b3
commit b9f43c24b8
5 changed files with 36 additions and 20 deletions

View File

@ -14,7 +14,7 @@ const ERROR_CODES := [
]
var userroot := OS.get_user_data_dir().rstrip('/')+'/' if OS.get_name() != 'Android' else '/storage/emulated/0/RhythmGame/'
var PATHS := [userroot]
var PATHS := [userroot, '/media/fridge-q/Games/Other/maimai Finale/decoded/RhythmGameCharts/slow_userdir/'] # Temporary hardcoded testing
# The following would probably work. One huge caveat is that permission needs to be manually granted by the user in app settings as we can't use OS.request_permission('WRITE_EXTERNAL_STORAGE')
# '/storage/emulated/0/Android/data/au.ufeff.rhythmgame/'
# '/sdcard/Android/data/au.ufeff.rhythmgame/'
@ -286,6 +286,7 @@ class RGT:
static func parse_rgtx(lines):
return [] # To be implemented later
const beats_per_measure = 4.0 # TODO: Bit of an ugly hack, need to revisit this later
static func parse_rgts(lines):
var notes = []
var slide_ids = {}
@ -298,12 +299,12 @@ class RGT:
if len(line) < 4: # shortest legal line would be like '1:1t'
continue
var s = line.split(':')
var time = float(s[0])
var time = float(s[0]) * beats_per_measure
var note_hits = []
var note_nonhits = []
for i in range(1, len(s)):
var n = s[i]
var column = n[0]
var column = int(n[0])
var ntype = n[1]
n = n.substr(2)
@ -313,7 +314,7 @@ class RGT:
'b': # break
note_hits.append(Note.NoteTap.new(time, column, true))
'h': # hold
var duration = float(n)
var duration = float(n) * beats_per_measure
note_hits.append(Note.NoteHold.new(time, column, duration))
's': # slide star
var star = Note.NoteStar.new(time, column)
@ -571,6 +572,12 @@ func load_filelist(filelist: Array, directory=''):
for filename in filelist:
var extension: String = filename.rsplit('.', true, 1)[-1]
filename = directory.rstrip('/') + '/' + filename
var file = File.new()
for root in PATHS:
var filename1 = root + filename
if file.file_exists(filename1):
filename = filename1
break
match extension:
'rgtm': # multiple charts
var res = RGT.load_file(filename)
@ -608,6 +615,15 @@ func load_ogg(filename) -> AudioStreamOGGVorbis:
return direct_load_ogg(filename1)
return fallback_audiostream
var fallback_videostream = VideoStreamWebm.new()
func load_video(filename):
var file = File.new()
for root in PATHS:
var filename1 = root + filename
if file.file_exists(filename1):
return load(filename1)
return fallback_videostream
func direct_load_image(filename) -> ImageTexture:
var tex := ImageTexture.new()
var img := Image.new()

View File

@ -4,7 +4,7 @@ extends Node
var receptor_ring_radius := 460.0
var note_forecast_beats := 2.0 # Notes start to appear this many beats before you need to tap them
const INNER_NOTE_CIRCLE_RATIO := 0.3 # Notes under this far from the center will zoom into existence
const SLIDE_DELAY := 0.5 # Time in beats between the tap of the star and the start of the visual slide
const SLIDE_DELAY := 0.5 #0.125 #0.5 # Time in beats between the tap of the star and the start of the visual slide
var sprite_size := 128
var sprite_size2 := sprite_size/2

View File

@ -69,11 +69,13 @@ class Song:
tile_filename = values.get('tile_filename', '%s.png'%values.get('index', 'tile'))
audio_filelist = values.get('audio_filelist', ['%s.ogg'%values.get('index', 'audio')])
video_filelist = values.get('video_filelist', ['%s.webm'%values.get('index', 'video')])
audio_offsets = values.get('audio_filelist', [240.0/BPM])
video_offsets = values.get('video_filelist', [240.0/BPM])
video_dimensions = values.get('video_dimensions', [1.0, 1.0])
audio_preview_times = values.get('video_dimensions', [1.0, 1.0])
genre = values.get('genre', 'None')
chart_filelist = values.get('chart_filelist', ['%s.rtgm'%values.get('index', 'charts')])
chart_filelist = values.get('chart_filelist', ['%s.rgtm'%values.get('index', 'charts')])
var diffs = values['chart_difficulties']
match typeof(diffs):
@ -125,7 +127,7 @@ func get_song_charts(song_key):
if song_key in charts_cache:
return charts_cache[song_key]
elif song_key in all_songs:
charts_cache[song_key] = FileLoader.load_filelist(all_songs[song_key].chart_filelist, all_songs[song_key].filepath)
charts_cache[song_key] = FileLoader.load_filelist(all_songs[song_key].chart_filelist, 'songs/'+all_songs[song_key].filepath)
return charts_cache[song_key]
else:
print_debug('Invalid song_key: ', song_key)

View File

@ -93,7 +93,7 @@ func _process(delta):
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 song_key = songslist[selected_song % len(songslist)]
NoteHandler.load_track(song_defs[song_key], selected_difficulty)
NoteHandler.load_track(song_key, selected_difficulty)
NoteHandler.running = true
func draw_string_centered(font, position, string, color := Color.white):
@ -187,7 +187,7 @@ func _draw_chart_select(center: Vector2) -> Array:
# TODO: This is relatively expensive so we probably want to calculate this stuff once instead of every frame
var all_notes = FileLoader.SRT.load_file(song_defs[song_key].directory + '/' + song_defs[song_key].chart_filelist[selected_difficulty])
var all_notes = Library.get_song_charts(song_key).values()[selected_difficulty]
var note_counts = {Note.NOTE_TAP: 0, Note.NOTE_HOLD: 0, Note.NOTE_STAR: 0}
for note in all_notes:
if note.type in note_counts:

View File

@ -565,21 +565,19 @@ func _ready():
InputHandler.connect('button_released', self, 'button_released')
InputHandler.connect('touchbutton_released', self, 'touchbutton_released')
func load_track(data: Dictionary, difficulty_idx: int):
func load_track(song_key: String, difficulty_idx: int):
self.song_key = song_key
set_time(-3.0)
active_notes = []
all_notes = []
next_note_to_load = 0
self.song_key = data.directory.rsplit('/', true, 1)[1]
all_notes = FileLoader.SRT.load_file(data.directory + '/' + data.chart_filelist[difficulty_idx])
bpm = data.bpm_values[0]
all_notes = Library.get_song_charts(song_key).values()[difficulty_idx]
var data = Library.all_songs[song_key]
bpm = data.BPM
sync_offset_audio = data.audio_offsets[0]
sync_offset_video = data.video_offsets[0]
var audiostream = FileLoader.direct_load_ogg(data.directory + '/' + data.audio_filelist[0])
var videostream = load(data.directory + '/' + data.video_filelist[0])
MusicPlayer.set_stream(audiostream)
VideoPlayer.set_stream(videostream)
MusicPlayer.set_stream(FileLoader.load_ogg('songs/' + data.filepath.rstrip('/') + '/' + data.audio_filelist[0]))
VideoPlayer.set_stream(FileLoader.load_video('songs/' + data.filepath.rstrip('/') + '/' + data.video_filelist[0]))
VideoPlayer.update_aspect_ratio(data.video_dimensions[0]/data.video_dimensions[1])
# all_notes = FileLoader.Test.stress_pattern()
@ -648,11 +646,11 @@ func _process(delta):
timer.connect('timeout', timer, 'queue_free')
var vt_delta := time - video_start_time()
if (0.0 <= vt_delta) and (vt_delta < 1.0) and not VideoPlayer.is_playing():
if (0.0 <= vt_delta) and (vt_delta < 3.0) and not VideoPlayer.is_playing():
VideoPlayer.play()
VideoPlayer.set_stream_position(vt_delta)
var at_delta := time - audio_start_time()
if (0.0 <= at_delta) and (at_delta < 1.0) and not MusicPlayer.is_playing():
if (0.0 <= at_delta) and (at_delta < 3.0) and not MusicPlayer.is_playing():
# MusicPlayer.play()
# MusicPlayer.seek(at_delta)
MusicPlayer.play(at_delta)