don't look inside .offset files

This commit is contained in:
Detoria
2021-04-13 19:43:18 -03:00
committed by GitHub
parent 7d11dc9081
commit 551f45ef4f
2 changed files with 89 additions and 6 deletions

View File

@ -39,6 +39,7 @@ import lime.utils.Assets;
import openfl.display.BlendMode;
import openfl.display.StageQuality;
import openfl.filters.ShaderFilter;
import Sys;
#if windows
import Discord.DiscordClient;
@ -180,6 +181,8 @@ class PlayState extends MusicBeatState
// Will decide if she's even allowed to headbang at all depending on the song
private var allowedToHeadbang:Bool = false;
// Per song additive offset
public static var songOffset:Float = 0;
override public function create()
{
@ -1226,6 +1229,24 @@ class PlayState extends MusicBeatState
var playerCounter:Int = 0;
// Per song offset check
var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/';
for(file in sys.FileSystem.readDirectory(songPath))
{
var path = haxe.io.Path.join([songPath, file]);
if(!sys.FileSystem.isDirectory(path))
{
if(path.endsWith('.offset'))
{
trace('Found offset file: ' + path);
songOffset = Std.parseFloat(file.substring(0, file.indexOf('.off')));
break;
}else {
trace('Offset file not found. Creating one @: ' + songPath);
sys.io.File.saveContent(songPath + songOffset + '.offset', '');
}
}
}
var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped
for (section in noteData)
{
@ -1233,7 +1254,7 @@ class PlayState extends MusicBeatState
for (songNotes in section.sectionNotes)
{
var daStrumTime:Float = songNotes[0] + FlxG.save.data.offset;
var daStrumTime:Float = songNotes[0] + FlxG.save.data.offset + songOffset;
if (daStrumTime < 0)
daStrumTime = 0;
var daNoteData:Int = Std.int(songNotes[1] % 4);
@ -3249,4 +3270,4 @@ class PlayState extends MusicBeatState
}
var curLight:Int = 0;
}
}