mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-09-11 20:57:20 +00:00
Work in progress
This commit is contained in:
parent
334d267ffc
commit
167976c8ba
2
assets
2
assets
|
@ -1 +1 @@
|
||||||
Subproject commit b2f8b6a780316959d0a79adc6dbf61f9e4ca675f
|
Subproject commit 5479e17b1085f72e05f1c1f9e0a668ef832d3341
|
|
@ -87,6 +87,12 @@ typedef PlayStateParams =
|
||||||
* @default `bf`, or the first character in the song's character list.
|
* @default `bf`, or the first character in the song's character list.
|
||||||
*/
|
*/
|
||||||
?targetCharacter:String,
|
?targetCharacter:String,
|
||||||
|
/**
|
||||||
|
* The instrumental to play with.
|
||||||
|
* Significant if the `targetSong` supports alternate instrumentals.
|
||||||
|
* @default `null`
|
||||||
|
*/
|
||||||
|
?targetInstrumental:String,
|
||||||
/**
|
/**
|
||||||
* Whether the song should start in Practice Mode.
|
* Whether the song should start in Practice Mode.
|
||||||
* @default `false`
|
* @default `false`
|
||||||
|
@ -448,7 +454,7 @@ class PlayState extends MusicBeatSubState
|
||||||
function get_currentChart():SongDifficulty
|
function get_currentChart():SongDifficulty
|
||||||
{
|
{
|
||||||
if (currentSong == null || currentDifficulty == null) return null;
|
if (currentSong == null || currentDifficulty == null) return null;
|
||||||
return currentSong.getDifficulty(currentDifficulty);
|
return currentSong.getDifficulty(currentDifficulty, currentPlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2650,14 +2656,17 @@ class PlayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
// Stop the music.
|
// Stop the music.
|
||||||
FlxG.sound.music.pause();
|
FlxG.sound.music.pause();
|
||||||
vocals.stop();
|
if (vocals != null) vocals.stop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FlxG.sound.music.pause();
|
FlxG.sound.music.pause();
|
||||||
|
if (vocals != null)
|
||||||
|
{
|
||||||
vocals.pause();
|
vocals.pause();
|
||||||
remove(vocals);
|
remove(vocals);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove reference to stage and remove sprites from it to save memory.
|
// Remove reference to stage and remove sprites from it to save memory.
|
||||||
if (currentStage != null)
|
if (currentStage != null)
|
||||||
|
|
|
@ -184,7 +184,10 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
|
|
||||||
difficulty.characters = metadata.playData.characters;
|
difficulty.characters = metadata.playData.characters;
|
||||||
|
|
||||||
difficulties.set(diffId, difficulty);
|
var variationSuffix = (metadata.variation != null
|
||||||
|
&& metadata.variation != ''
|
||||||
|
&& metadata.variation != Constants.DEFAULT_VARIATION) ? '-${metadata.variation}' : '';
|
||||||
|
difficulties.set('$diffId$variationSuffix', difficulty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +227,8 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
trace('Fabricated new difficulty for $diffId.');
|
trace('Fabricated new difficulty for $diffId.');
|
||||||
difficulty = new SongDifficulty(this, diffId, variation);
|
difficulty = new SongDifficulty(this, diffId, variation);
|
||||||
var metadata = _metadata.get(variation);
|
var metadata = _metadata.get(variation);
|
||||||
difficulties.set(diffId, difficulty);
|
var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : '';
|
||||||
|
difficulties.set('$diffId$variationSuffix', difficulty);
|
||||||
|
|
||||||
if (metadata != null)
|
if (metadata != null)
|
||||||
{
|
{
|
||||||
|
@ -256,11 +260,14 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
* @param diffId The difficulty ID, such as `easy` or `hard`.
|
* @param diffId The difficulty ID, such as `easy` or `hard`.
|
||||||
* @return The difficulty data.
|
* @return The difficulty data.
|
||||||
*/
|
*/
|
||||||
public inline function getDifficulty(?diffId:String):Null<SongDifficulty>
|
public inline function getDifficulty(?diffId:String, ?variation:String):Null<SongDifficulty>
|
||||||
{
|
{
|
||||||
if (diffId == null) diffId = listDifficulties()[0];
|
if (diffId == null) diffId = listDifficulties()[0];
|
||||||
|
|
||||||
return difficulties.get(diffId);
|
if (variation == null) variation = Constants.DEFAULT_VARIATION;
|
||||||
|
var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : '';
|
||||||
|
|
||||||
|
return difficulties.get('$diffId$variationSuffix');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,12 +279,16 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
{
|
{
|
||||||
if (variationId == '') variationId = null;
|
if (variationId == '') variationId = null;
|
||||||
|
|
||||||
var diffFiltered:Array<String> = difficulties.keys().array().filter(function(diffId:String):Bool {
|
// The difficulties array contains entries like 'normal', 'nightmare-erect', and 'normal-pico',
|
||||||
if (variationId == null) return true;
|
// so we have to map it to the actual difficulty names.
|
||||||
|
// We also filter out difficulties that don't match the variation or that don't exist.
|
||||||
|
|
||||||
|
var diffFiltered:Array<String> = difficulties.keys().array().map(function(diffId:String):Null<String> {
|
||||||
var difficulty:Null<SongDifficulty> = difficulties.get(diffId);
|
var difficulty:Null<SongDifficulty> = difficulties.get(diffId);
|
||||||
if (difficulty == null) return false;
|
if (difficulty == null) return null;
|
||||||
return difficulty.variation == variationId;
|
if (variationId != null && difficulty.variation != variationId) return null;
|
||||||
});
|
return difficulty.difficulty;
|
||||||
|
}).nonNull().unique();
|
||||||
|
|
||||||
diffFiltered.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST));
|
diffFiltered.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST));
|
||||||
|
|
||||||
|
@ -286,8 +297,9 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
|
|
||||||
public function hasDifficulty(diffId:String, ?variationId:String):Bool
|
public function hasDifficulty(diffId:String, ?variationId:String):Bool
|
||||||
{
|
{
|
||||||
if (variationId == '') variationId = null;
|
if (variationId == '') variationId = Constants.DEFAULT_VARIATION;
|
||||||
var difficulty:Null<SongDifficulty> = difficulties.get(diffId);
|
var variationSuffix:String = (variationId == Constants.DEFAULT_VARIATION) ? '' : '-$variationId';
|
||||||
|
var difficulty:Null<SongDifficulty> = difficulties.get('$diffId$variationSuffix');
|
||||||
return variationId == null ? (difficulty != null) : (difficulty != null && difficulty.variation == variationId);
|
return variationId == null ? (difficulty != null) : (difficulty != null && difficulty.variation == variationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,14 @@ import funkin.util.MathUtil;
|
||||||
import lime.app.Future;
|
import lime.app.Future;
|
||||||
import lime.utils.Assets;
|
import lime.utils.Assets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parameters used to initialize the FreeplayState.
|
||||||
|
*/
|
||||||
|
typedef FreeplayStateParams =
|
||||||
|
{
|
||||||
|
?character:String;
|
||||||
|
};
|
||||||
|
|
||||||
class FreeplayState extends MusicBeatSubState
|
class FreeplayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
var songs:Array<Null<FreeplaySongData>> = [];
|
var songs:Array<Null<FreeplaySongData>> = [];
|
||||||
|
@ -64,6 +72,9 @@ class FreeplayState extends MusicBeatSubState
|
||||||
var curSelected:Int = 0;
|
var curSelected:Int = 0;
|
||||||
var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
||||||
|
|
||||||
|
// Params
|
||||||
|
var currentCharacter:String;
|
||||||
|
|
||||||
var fp:FreeplayScore;
|
var fp:FreeplayScore;
|
||||||
var txtCompletion:AtlasText;
|
var txtCompletion:AtlasText;
|
||||||
var lerpCompletion:Float = 0;
|
var lerpCompletion:Float = 0;
|
||||||
|
@ -99,12 +110,13 @@ class FreeplayState extends MusicBeatSubState
|
||||||
|
|
||||||
var stickerSubState:StickerSubState;
|
var stickerSubState:StickerSubState;
|
||||||
|
|
||||||
//
|
|
||||||
static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
|
static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
|
||||||
static var rememberedSongId:Null<String> = null;
|
static var rememberedSongId:Null<String> = null;
|
||||||
|
|
||||||
public function new(?stickers:StickerSubState = null)
|
public function new(?params:FreeplayParams, ?stickers:StickerSubState)
|
||||||
{
|
{
|
||||||
|
currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER;
|
||||||
|
|
||||||
if (stickers != null)
|
if (stickers != null)
|
||||||
{
|
{
|
||||||
stickerSubState = stickers;
|
stickerSubState = stickers;
|
||||||
|
@ -844,6 +856,13 @@ class FreeplayState extends MusicBeatSubState
|
||||||
changeDiff(1);
|
changeDiff(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: DEBUG REMOVE THIS
|
||||||
|
if (FlxG.keys.justPressed.P)
|
||||||
|
{
|
||||||
|
currentCharacter = (currentCharacter == "bf") ? "pico" : "bf";
|
||||||
|
changeSelection(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (controls.BACK && !typing.hasFocus)
|
if (controls.BACK && !typing.hasFocus)
|
||||||
{
|
{
|
||||||
FlxTween.globalManager.clear();
|
FlxTween.globalManager.clear();
|
||||||
|
|
|
@ -23,6 +23,24 @@ class ArrayTools
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of the array with all `null` elements removed.
|
||||||
|
* @param array The array to remove `null` elements from.
|
||||||
|
* @return A copy of the array with all `null` elements removed.
|
||||||
|
*/
|
||||||
|
public static function nonNull<T>(array:Array<Null<T>>):Array<T>
|
||||||
|
{
|
||||||
|
var result:Array<T> = [];
|
||||||
|
for (element in array)
|
||||||
|
{
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
result.push(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the first element of the array that satisfies the predicate, or null if none do.
|
* Return the first element of the array that satisfies the predicate, or null if none do.
|
||||||
* @param input The array to search
|
* @param input The array to search
|
||||||
|
|
Loading…
Reference in a new issue