Merge remote-tracking branch 'upstream/master' into patch-3

This commit is contained in:
Lucky56
2021-06-26 12:45:39 +02:00
33 changed files with 1167 additions and 437 deletions

View File

@ -1,5 +1,7 @@
package;
import Song.SwagSong;
import flixel.input.gamepad.FlxGamepad;
import flash.text.TextField;
import flixel.FlxG;
import flixel.FlxSprite;
@ -28,6 +30,7 @@ class FreeplayState extends MusicBeatState
var scoreText:FlxText;
var comboText:FlxText;
var diffText:FlxText;
var diffCalcText:FlxText;
var lerpScore:Int = 0;
var intendedScore:Int = 0;
var combo:String = '';
@ -37,6 +40,20 @@ class FreeplayState extends MusicBeatState
private var iconArray:Array<HealthIcon> = [];
public static var songData:Map<String,Array<SwagSong>> = [];
public static function loadDiff(diff:Int, format:String, name:String, array:Array<SwagSong>)
{
try
{
array.push(Song.loadFromJson(Highscore.formatSong(format, diff), name));
}
catch(ex)
{
// do nada
}
}
override function create()
{
var initSonglist = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist'));
@ -44,8 +61,23 @@ class FreeplayState extends MusicBeatState
for (i in 0...initSonglist.length)
{
var data:Array<String> = initSonglist[i].split(':');
var meta = new SongMetadata(data[0], Std.parseInt(data[2]), data[1]);
if(Std.parseInt(data[2]) <= FlxG.save.data.weekUnlocked - 1)
songs.push(new SongMetadata(data[0], Std.parseInt(data[2]), data[1]));
songs.push(meta);
var format = StringTools.replace(meta.songName, " ", "-");
switch (format) {
case 'Dad-Battle': format = 'Dadbattle';
case 'Philly-Nice': format = 'Philly';
}
var diffs = [];
FreeplayState.loadDiff(0,format,meta.songName,diffs);
FreeplayState.loadDiff(1,format,meta.songName,diffs);
FreeplayState.loadDiff(2,format,meta.songName,diffs);
FreeplayState.songData.set(meta.songName,diffs);
trace('loaded diffs for ' + meta.songName);
}
/*
@ -101,7 +133,7 @@ class FreeplayState extends MusicBeatState
scoreText.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, RIGHT);
// scoreText.alignment = RIGHT;
var scoreBG:FlxSprite = new FlxSprite(scoreText.x - 6, 0).makeGraphic(Std.int(FlxG.width * 0.35), 66, 0xFF000000);
var scoreBG:FlxSprite = new FlxSprite(scoreText.x - 6, 0).makeGraphic(Std.int(FlxG.width * 0.35), 105, 0xFF000000);
scoreBG.alpha = 0.6;
add(scoreBG);
@ -109,6 +141,10 @@ class FreeplayState extends MusicBeatState
diffText.font = scoreText.font;
add(diffText);
diffCalcText = new FlxText(scoreText.x, scoreText.y + 66, 0, "", 24);
diffCalcText.font = scoreText.font;
add(diffCalcText);
comboText = new FlxText(diffText.x + 100, diffText.y, 0, "", 24);
comboText.font = diffText.font;
add(comboText);
@ -185,10 +221,32 @@ class FreeplayState extends MusicBeatState
scoreText.text = "PERSONAL BEST:" + lerpScore;
comboText.text = combo + '\n';
var upP = controls.UP_P;
var downP = controls.DOWN_P;
var upP = FlxG.keys.justPressed.UP;
var downP = FlxG.keys.justPressed.DOWN;
var accepted = controls.ACCEPT;
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.DPAD_UP)
{
changeSelection(-1);
}
if (gamepad.justPressed.DPAD_DOWN)
{
changeSelection(1);
}
if (gamepad.justPressed.DPAD_LEFT)
{
changeDiff(-1);
}
if (gamepad.justPressed.DPAD_RIGHT)
{
changeDiff(1);
}
}
if (upP)
{
changeSelection(-1);
@ -198,9 +256,9 @@ class FreeplayState extends MusicBeatState
changeSelection(1);
}
if (controls.LEFT_P)
if (FlxG.keys.justPressed.LEFT)
changeDiff(-1);
if (controls.RIGHT_P)
if (FlxG.keys.justPressed.RIGHT)
changeDiff(1);
if (controls.BACK)
@ -216,14 +274,20 @@ class FreeplayState extends MusicBeatState
case 'Dad-Battle': songFormat = 'Dadbattle';
case 'Philly-Nice': songFormat = 'Philly';
}
trace(songs[curSelected].songName);
var hmm;
try
{
hmm = songData.get(songs[curSelected].songName)[curDifficulty];
if (hmm == null)
return;
}
catch(ex)
{
return;
}
var poop:String = Highscore.formatSong(songFormat, curDifficulty);
trace(poop);
PlayState.SONG = Song.loadFromJson(poop, songs[curSelected].songName);
PlayState.SONG = hmm;
PlayState.isStoryMode = false;
PlayState.storyDifficulty = curDifficulty;
PlayState.storyWeek = songs[curSelected].week;
@ -252,7 +316,7 @@ class FreeplayState extends MusicBeatState
intendedScore = Highscore.getScore(songHighscore, curDifficulty);
combo = Highscore.getCombo(songHighscore, curDifficulty);
#end
diffCalcText.text = 'RATING: ${DiffCalc.CalculateDiff(songData.get(songs[curSelected].songName)[curDifficulty])}';
diffText.text = CoolUtil.difficultyFromInt(curDifficulty).toUpperCase();
}
@ -288,6 +352,8 @@ class FreeplayState extends MusicBeatState
// lerpScore = 0;
#end
diffCalcText.text = 'RATING: ${DiffCalc.CalculateDiff(songData.get(songs[curSelected].songName)[curDifficulty])}';
#if PRELOAD_ALL
FlxG.sound.playMusic(Paths.inst(songs[curSelected].songName), 0);
#end