mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-23 10:29:29 +00:00
Reworks to make Pico mode actually work.
This commit is contained in:
parent
e5fb1de4ba
commit
82b63c02e1
2
assets
2
assets
|
@ -1 +1 @@
|
||||||
Subproject commit 5479e17b1085f72e05f1c1f9e0a668ef832d3341
|
Subproject commit 49970e24e919de25f4dcef5bd47116f1877ee360
|
|
@ -915,6 +915,28 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
|
||||||
return SongNoteData.buildDirectionName(this.data, strumlineSize);
|
return SongNoteData.buildDirectionName(this.data, strumlineSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The strumline index of the note, if applicable.
|
||||||
|
* Strips the direction from the data.
|
||||||
|
*
|
||||||
|
* 0 = player, 1 = opponent, etc.
|
||||||
|
*/
|
||||||
|
public function getStrumlineIndex(strumlineSize:Int = 4):Int
|
||||||
|
{
|
||||||
|
return Math.floor(this.data / strumlineSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the note is one that Boyfriend should try to hit (i.e. it's on his side).
|
||||||
|
* TODO: The name of this function is a little misleading; what about mines?
|
||||||
|
* @param strumlineSize Defaults to 4.
|
||||||
|
* @return True if it's Boyfriend's note.
|
||||||
|
*/
|
||||||
|
public function getMustHitNote(strumlineSize:Int = 4):Bool
|
||||||
|
{
|
||||||
|
return getStrumlineIndex(strumlineSize) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
@:jignored
|
@:jignored
|
||||||
var _stepTime:Null<Float> = null;
|
var _stepTime:Null<Float> = null;
|
||||||
|
|
||||||
|
@ -1003,28 +1025,6 @@ abstract SongNoteData(SongNoteDataRaw) from SongNoteDataRaw to SongNoteDataRaw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The strumline index of the note, if applicable.
|
|
||||||
* Strips the direction from the data.
|
|
||||||
*
|
|
||||||
* 0 = player, 1 = opponent, etc.
|
|
||||||
*/
|
|
||||||
public inline function getStrumlineIndex(strumlineSize:Int = 4):Int
|
|
||||||
{
|
|
||||||
return Math.floor(this.data / strumlineSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the note is one that Boyfriend should try to hit (i.e. it's on his side).
|
|
||||||
* TODO: The name of this function is a little misleading; what about mines?
|
|
||||||
* @param strumlineSize Defaults to 4.
|
|
||||||
* @return True if it's Boyfriend's note.
|
|
||||||
*/
|
|
||||||
public inline function getMustHitNote(strumlineSize:Int = 4):Bool
|
|
||||||
{
|
|
||||||
return getStrumlineIndex(strumlineSize) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@:jignored
|
@:jignored
|
||||||
public var isHoldNote(get, never):Bool;
|
public var isHoldNote(get, never):Bool;
|
||||||
|
|
||||||
|
|
|
@ -234,11 +234,11 @@ class PauseSubState extends MusicBeatSubState
|
||||||
if (PlayStatePlaylist.isStoryMode)
|
if (PlayStatePlaylist.isStoryMode)
|
||||||
{
|
{
|
||||||
PlayStatePlaylist.reset();
|
PlayStatePlaylist.reset();
|
||||||
openSubState(new funkin.ui.transition.StickerSubState(null, () -> new funkin.ui.story.StoryMenuState()));
|
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.story.StoryMenuState()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
openSubState(new funkin.ui.transition.StickerSubState(null, () -> new funkin.ui.freeplay.FreeplayState()));
|
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.freeplay.FreeplayState(null, sticker)));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'Exit to Chart Editor':
|
case 'Exit to Chart Editor':
|
||||||
|
|
|
@ -83,10 +83,10 @@ typedef PlayStateParams =
|
||||||
*/
|
*/
|
||||||
?targetDifficulty:String,
|
?targetDifficulty:String,
|
||||||
/**
|
/**
|
||||||
* The character to play as.
|
* The variation to play on.
|
||||||
* @default `bf`, or the first character in the song's character list.
|
* @default `Constants.DEFAULT_VARIATION` .
|
||||||
*/
|
*/
|
||||||
?targetCharacter:String,
|
?targetVariation:String,
|
||||||
/**
|
/**
|
||||||
* The instrumental to play with.
|
* The instrumental to play with.
|
||||||
* Significant if the `targetSong` supports alternate instrumentals.
|
* Significant if the `targetSong` supports alternate instrumentals.
|
||||||
|
@ -153,9 +153,9 @@ class PlayState extends MusicBeatSubState
|
||||||
public var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
public var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player character being used for this level, as a character ID.
|
* The currently selected variation.
|
||||||
*/
|
*/
|
||||||
public var currentPlayerId:String = 'bf';
|
public var currentVariation:String = Constants.DEFAULT_VARIATION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currently active Stage. This is the object containing all the props.
|
* The currently active Stage. This is the object containing all the props.
|
||||||
|
@ -454,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, currentPlayerId);
|
return currentSong.getDifficulty(currentDifficulty, currentVariation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -512,7 +512,7 @@ class PlayState extends MusicBeatSubState
|
||||||
// Apply parameters.
|
// Apply parameters.
|
||||||
currentSong = params.targetSong;
|
currentSong = params.targetSong;
|
||||||
if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty;
|
if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty;
|
||||||
if (params.targetCharacter != null) currentPlayerId = params.targetCharacter;
|
if (params.targetVariation != null) currentVariation = params.targetVariation;
|
||||||
isPracticeMode = params.practiceMode ?? false;
|
isPracticeMode = params.practiceMode ?? false;
|
||||||
isMinimalMode = params.minimalMode ?? false;
|
isMinimalMode = params.minimalMode ?? false;
|
||||||
startTimestamp = params.startTimestamp ?? 0.0;
|
startTimestamp = params.startTimestamp ?? 0.0;
|
||||||
|
@ -692,7 +692,7 @@ class PlayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
else if (currentChart == null)
|
else if (currentChart == null)
|
||||||
{
|
{
|
||||||
message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty playing as "$currentPlayerId". Click OK to return to the main menu.';
|
message = 'The was a critical error retrieving data for this song on "$currentDifficulty" difficulty with variation "$currentVariation". Click OK to return to the main menu.';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display a popup. This blocks the application until the user clicks OK.
|
// Display a popup. This blocks the application until the user clicks OK.
|
||||||
|
@ -838,7 +838,7 @@ class PlayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
targetSong: currentSong,
|
targetSong: currentSong,
|
||||||
targetDifficulty: currentDifficulty,
|
targetDifficulty: currentDifficulty,
|
||||||
targetCharacter: currentPlayerId,
|
targetVariation: currentVariation,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1395,7 +1395,7 @@ class PlayState extends MusicBeatSubState
|
||||||
trace('Song difficulty could not be loaded.');
|
trace('Song difficulty could not be loaded.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentCharacterData:SongCharacterData = currentChart.characters; // Switch the character we are playing as by manipulating currentPlayerId.
|
var currentCharacterData:SongCharacterData = currentChart.characters; // Switch the variation we are playing on by manipulating targetVariation.
|
||||||
|
|
||||||
//
|
//
|
||||||
// GIRLFRIEND
|
// GIRLFRIEND
|
||||||
|
@ -2600,7 +2600,7 @@ class PlayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
targetSong: targetSong,
|
targetSong: targetSong,
|
||||||
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
||||||
targetCharacter: currentPlayerId,
|
targetVariation: currentVariation,
|
||||||
});
|
});
|
||||||
nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y);
|
nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y);
|
||||||
return nextPlayState;
|
return nextPlayState;
|
||||||
|
@ -2618,7 +2618,7 @@ class PlayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
targetSong: targetSong,
|
targetSong: targetSong,
|
||||||
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
|
||||||
targetCharacter: currentPlayerId,
|
targetVariation: currentVariation,
|
||||||
});
|
});
|
||||||
nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y);
|
nextPlayState.previousCameraFollowPoint = new FlxSprite(cameraFollowPoint.x, cameraFollowPoint.y);
|
||||||
return nextPlayState;
|
return nextPlayState;
|
||||||
|
|
|
@ -148,11 +148,12 @@ class HealthIcon extends FlxSprite
|
||||||
{
|
{
|
||||||
if (characterId == 'bf-old')
|
if (characterId == 'bf-old')
|
||||||
{
|
{
|
||||||
characterId = PlayState.instance.currentPlayerId;
|
PlayState.instance.currentStage.getBoyfriend().initHealthIcon(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
characterId = 'bf-old';
|
characterId = 'bf-old';
|
||||||
|
loadCharacter(characterId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,9 +184,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
|
|
||||||
difficulty.characters = metadata.playData.characters;
|
difficulty.characters = metadata.playData.characters;
|
||||||
|
|
||||||
var variationSuffix = (metadata.variation != null
|
var variationSuffix = (metadata.variation != Constants.DEFAULT_VARIATION) ? '-${metadata.variation}' : '';
|
||||||
&& metadata.variation != ''
|
|
||||||
&& metadata.variation != Constants.DEFAULT_VARIATION) ? '-${metadata.variation}' : '';
|
|
||||||
difficulties.set('$diffId$variationSuffix', difficulty);
|
difficulties.set('$diffId$variationSuffix', difficulty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,13 +219,13 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
for (diffId in chartNotes.keys())
|
for (diffId in chartNotes.keys())
|
||||||
{
|
{
|
||||||
// Retrieve the cached difficulty data.
|
// Retrieve the cached difficulty data.
|
||||||
var difficulty:Null<SongDifficulty> = difficulties.get(diffId);
|
var variationSuffix = (variation != Constants.DEFAULT_VARIATION) ? '-$variation' : '';
|
||||||
|
var difficulty:Null<SongDifficulty> = difficulties.get('$diffId$variationSuffix');
|
||||||
if (difficulty == null)
|
if (difficulty == null)
|
||||||
{
|
{
|
||||||
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);
|
||||||
var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : '';
|
|
||||||
difficulties.set('$diffId$variationSuffix', difficulty);
|
difficulties.set('$diffId$variationSuffix', difficulty);
|
||||||
|
|
||||||
if (metadata != null)
|
if (metadata != null)
|
||||||
|
@ -258,26 +256,52 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
/**
|
/**
|
||||||
* Retrieve the metadata for a specific difficulty, including the chart if it is loaded.
|
* Retrieve the metadata for a specific difficulty, including the chart if it is loaded.
|
||||||
* @param diffId The difficulty ID, such as `easy` or `hard`.
|
* @param diffId The difficulty ID, such as `easy` or `hard`.
|
||||||
|
* @param variation The variation ID to fetch the difficulty for. Or you can use `variations`.
|
||||||
|
* @param variations A list of variations to fetch the difficulty for. Looks for the first variation that exists.
|
||||||
* @return The difficulty data.
|
* @return The difficulty data.
|
||||||
*/
|
*/
|
||||||
public inline function getDifficulty(?diffId:String, ?variation:String):Null<SongDifficulty>
|
public function getDifficulty(?diffId:String, ?variation:String, ?variations:Array<String>):Null<SongDifficulty>
|
||||||
{
|
{
|
||||||
if (diffId == null) diffId = listDifficulties()[0];
|
if (diffId == null) diffId = listDifficulties(variation)[0];
|
||||||
|
|
||||||
if (variation == null) variation = Constants.DEFAULT_VARIATION;
|
if (variation == null) variation = Constants.DEFAULT_VARIATION;
|
||||||
var variationSuffix = (variation != null && variation != '' && variation != Constants.DEFAULT_VARIATION) ? '-$variation' : '';
|
if (variations == null) variations = [variation];
|
||||||
|
|
||||||
|
for (currentVariation in variations)
|
||||||
|
{
|
||||||
|
var variationSuffix = (currentVariation != Constants.DEFAULT_VARIATION) ? '-$currentVariation' : '';
|
||||||
|
|
||||||
|
if (difficulties.exists('$diffId$variationSuffix'))
|
||||||
|
{
|
||||||
return difficulties.get('$diffId$variationSuffix');
|
return difficulties.get('$diffId$variationSuffix');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFirstValidVariation(?diffId:String, ?possibleVariations:Array<String>):Null<String>
|
||||||
|
{
|
||||||
|
if (variations == null) possibleVariations = variations;
|
||||||
|
if (diffId == null) diffId = listDifficulties(null, possibleVariations)[0];
|
||||||
|
|
||||||
|
for (variation in variations)
|
||||||
|
{
|
||||||
|
if (difficulties.exists('$diffId-$variation')) return variation;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all the difficulties in this song.
|
* List all the difficulties in this song.
|
||||||
* @param variationId Optionally filter by variation.
|
* @param variationId Optionally filter by a single variation.
|
||||||
|
* @param variationIds Optionally filter by multiple variations.
|
||||||
* @return The list of difficulties.
|
* @return The list of difficulties.
|
||||||
*/
|
*/
|
||||||
public function listDifficulties(?variationId:String):Array<String>
|
public function listDifficulties(?variationId:String, ?variationIds:Array<String>):Array<String>
|
||||||
{
|
{
|
||||||
if (variationId == '') variationId = null;
|
if (variationIds == null) variationIds = [];
|
||||||
|
if (variationId != null) variationIds.push(variationId);
|
||||||
|
|
||||||
// The difficulties array contains entries like 'normal', 'nightmare-erect', and 'normal-pico',
|
// The difficulties array contains entries like 'normal', 'nightmare-erect', and 'normal-pico',
|
||||||
// so we have to map it to the actual difficulty names.
|
// so we have to map it to the actual difficulty names.
|
||||||
|
@ -286,7 +310,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
||||||
var diffFiltered:Array<String> = difficulties.keys().array().map(function(diffId:String):Null<String> {
|
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 null;
|
if (difficulty == null) return null;
|
||||||
if (variationId != null && difficulty.variation != variationId) return null;
|
if (variationIds.length > 0 && !variationIds.contains(difficulty.variation)) return null;
|
||||||
return difficulty.difficulty;
|
return difficulty.difficulty;
|
||||||
}).nonNull().unique();
|
}).nonNull().unique();
|
||||||
|
|
||||||
|
@ -504,7 +528,8 @@ class SongDifficulty
|
||||||
var suffix:String = (variation != null && variation != '' && variation != 'default') ? '-$variation' : '';
|
var suffix:String = (variation != null && variation != '' && variation != 'default') ? '-$variation' : '';
|
||||||
|
|
||||||
// Automatically resolve voices by removing suffixes.
|
// Automatically resolve voices by removing suffixes.
|
||||||
// For example, if `Voices-bf-car.ogg` does not exist, check for `Voices-bf.ogg`.
|
// For example, if `Voices-bf-car-erect.ogg` does not exist, check for `Voices-bf-erect.ogg`.
|
||||||
|
// Then, check for `Voices-bf-car.ogg`, then `Voices-bf.ogg`.
|
||||||
|
|
||||||
var playerId:String = characters.player;
|
var playerId:String = characters.player;
|
||||||
var voicePlayer:String = Paths.voices(this.song.id, '-$playerId$suffix');
|
var voicePlayer:String = Paths.voices(this.song.id, '-$playerId$suffix');
|
||||||
|
@ -516,6 +541,19 @@ class SongDifficulty
|
||||||
// Try again.
|
// Try again.
|
||||||
voicePlayer = playerId == '' ? null : Paths.voices(this.song.id, '-${playerId}$suffix');
|
voicePlayer = playerId == '' ? null : Paths.voices(this.song.id, '-${playerId}$suffix');
|
||||||
}
|
}
|
||||||
|
if (voicePlayer == null)
|
||||||
|
{
|
||||||
|
// Try again without $suffix.
|
||||||
|
playerId = characters.player;
|
||||||
|
voicePlayer = Paths.voices(this.song.id, '-${playerId}');
|
||||||
|
while (voicePlayer != null && !Assets.exists(voicePlayer))
|
||||||
|
{
|
||||||
|
// Remove the last suffix.
|
||||||
|
playerId = playerId.split('-').slice(0, -1).join('-');
|
||||||
|
// Try again.
|
||||||
|
voicePlayer = playerId == '' ? null : Paths.voices(this.song.id, '-${playerId}$suffix');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var opponentId:String = characters.opponent;
|
var opponentId:String = characters.opponent;
|
||||||
var voiceOpponent:String = Paths.voices(this.song.id, '-${opponentId}$suffix');
|
var voiceOpponent:String = Paths.voices(this.song.id, '-${opponentId}$suffix');
|
||||||
|
@ -526,6 +564,19 @@ class SongDifficulty
|
||||||
// Try again.
|
// Try again.
|
||||||
voiceOpponent = opponentId == '' ? null : Paths.voices(this.song.id, '-${opponentId}$suffix');
|
voiceOpponent = opponentId == '' ? null : Paths.voices(this.song.id, '-${opponentId}$suffix');
|
||||||
}
|
}
|
||||||
|
if (voiceOpponent == null)
|
||||||
|
{
|
||||||
|
// Try again without $suffix.
|
||||||
|
opponentId = characters.opponent;
|
||||||
|
voiceOpponent = Paths.voices(this.song.id, '-${opponentId}');
|
||||||
|
while (voiceOpponent != null && !Assets.exists(voiceOpponent))
|
||||||
|
{
|
||||||
|
// Remove the last suffix.
|
||||||
|
opponentId = opponentId.split('-').slice(0, -1).join('-');
|
||||||
|
// Try again.
|
||||||
|
voiceOpponent = opponentId == '' ? null : Paths.voices(this.song.id, '-${opponentId}$suffix');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var result:Array<String> = [];
|
var result:Array<String> = [];
|
||||||
if (voicePlayer != null) result.push(voicePlayer);
|
if (voicePlayer != null) result.push(voicePlayer);
|
||||||
|
|
|
@ -5303,8 +5303,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
{
|
{
|
||||||
targetSong: targetSong,
|
targetSong: targetSong,
|
||||||
targetDifficulty: selectedDifficulty,
|
targetDifficulty: selectedDifficulty,
|
||||||
// TODO: Add this.
|
targetVariation: selectedVariation,
|
||||||
// targetCharacter: targetCharacter,
|
|
||||||
practiceMode: playtestPracticeMode,
|
practiceMode: playtestPracticeMode,
|
||||||
minimalMode: minimal,
|
minimalMode: minimal,
|
||||||
startTimestamp: startTimestamp,
|
startTimestamp: startTimestamp,
|
||||||
|
|
|
@ -70,11 +70,10 @@ class ChartEditorImportExportHandler
|
||||||
{
|
{
|
||||||
state.loadInstFromAsset(Paths.inst(songId, '-$variation'), variation);
|
state.loadInstFromAsset(Paths.inst(songId, '-$variation'), variation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (difficultyId in song.listDifficulties())
|
for (difficultyId in song.listDifficulties(variation))
|
||||||
{
|
{
|
||||||
var diff:Null<SongDifficulty> = song.getDifficulty(difficultyId);
|
var diff:Null<SongDifficulty> = song.getDifficulty(difficultyId, variation);
|
||||||
if (diff == null) continue;
|
if (diff == null) continue;
|
||||||
|
|
||||||
var instId:String = diff.variation == Constants.DEFAULT_VARIATION ? '' : diff.variation;
|
var instId:String = diff.variation == Constants.DEFAULT_VARIATION ? '' : diff.variation;
|
||||||
|
@ -94,6 +93,7 @@ class ChartEditorImportExportHandler
|
||||||
trace('[WARN] Strange quantity of voice paths for difficulty ${difficultyId}: ${voiceList.length}');
|
trace('[WARN] Strange quantity of voice paths for difficulty ${difficultyId}: ${voiceList.length}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
state.isHaxeUIDialogOpen = false;
|
state.isHaxeUIDialogOpen = false;
|
||||||
state.currentWorkingFilePath = null; // New file, so no path.
|
state.currentWorkingFilePath = null; // New file, so no path.
|
||||||
|
|
|
@ -59,11 +59,14 @@ import lime.utils.Assets;
|
||||||
*/
|
*/
|
||||||
typedef FreeplayStateParams =
|
typedef FreeplayStateParams =
|
||||||
{
|
{
|
||||||
?character:String;
|
?character:String,
|
||||||
};
|
};
|
||||||
|
|
||||||
class FreeplayState extends MusicBeatSubState
|
class FreeplayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
|
// Params, you can't change these without transitioning to a new FreeplayState.
|
||||||
|
final currentCharacter:String;
|
||||||
|
|
||||||
var songs:Array<Null<FreeplaySongData>> = [];
|
var songs:Array<Null<FreeplaySongData>> = [];
|
||||||
|
|
||||||
var diffIdsCurrent:Array<String> = [];
|
var diffIdsCurrent:Array<String> = [];
|
||||||
|
@ -72,9 +75,6 @@ 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;
|
||||||
|
@ -102,6 +102,8 @@ class FreeplayState extends MusicBeatSubState
|
||||||
var ostName:FlxText;
|
var ostName:FlxText;
|
||||||
var difficultyStars:DifficultyStars;
|
var difficultyStars:DifficultyStars;
|
||||||
|
|
||||||
|
var displayedVariations:Array<String>;
|
||||||
|
|
||||||
var dj:DJBoyfriend;
|
var dj:DJBoyfriend;
|
||||||
|
|
||||||
var letterSort:LetterSort;
|
var letterSort:LetterSort;
|
||||||
|
@ -113,7 +115,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
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(?params:FreeplayParams, ?stickers:StickerSubState)
|
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
|
||||||
{
|
{
|
||||||
currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER;
|
currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER;
|
||||||
|
|
||||||
|
@ -159,6 +161,10 @@ class FreeplayState extends MusicBeatSubState
|
||||||
// Add a null entry that represents the RANDOM option
|
// Add a null entry that represents the RANDOM option
|
||||||
songs.push(null);
|
songs.push(null);
|
||||||
|
|
||||||
|
// TODO: This makes custom variations disappear from Freeplay. Figure out a better solution later.
|
||||||
|
// Default character (BF) shows default and Erect variations. Pico shows only Pico variations.
|
||||||
|
displayedVariations = (currentCharacter == "bf") ? [Constants.DEFAULT_VARIATION, "erect"] : [currentCharacter];
|
||||||
|
|
||||||
// programmatically adds the songs via LevelRegistry and SongRegistry
|
// programmatically adds the songs via LevelRegistry and SongRegistry
|
||||||
for (levelId in LevelRegistry.instance.listBaseGameLevelIds())
|
for (levelId in LevelRegistry.instance.listBaseGameLevelIds())
|
||||||
{
|
{
|
||||||
|
@ -166,9 +172,12 @@ class FreeplayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
var song:Song = SongRegistry.instance.fetchEntry(songId);
|
var song:Song = SongRegistry.instance.fetchEntry(songId);
|
||||||
|
|
||||||
songs.push(new FreeplaySongData(levelId, songId, song));
|
// Only display songs which actually have available charts for the current character.
|
||||||
|
var availableDifficultiesForSong = song.listDifficulties(displayedVariations);
|
||||||
|
if (availableDifficultiesForSong.length == 0) continue;
|
||||||
|
|
||||||
for (difficulty in song.listDifficulties())
|
songs.push(new FreeplaySongData(levelId, songId, song, displayedVariations));
|
||||||
|
for (difficulty in availableDifficultiesForSong)
|
||||||
{
|
{
|
||||||
diffIdsTotal.pushUnique(difficulty);
|
diffIdsTotal.pushUnique(difficulty);
|
||||||
}
|
}
|
||||||
|
@ -287,6 +296,8 @@ class FreeplayState extends MusicBeatSubState
|
||||||
x: -dj.width * 1.6,
|
x: -dj.width * 1.6,
|
||||||
speed: 0.5
|
speed: 0.5
|
||||||
});
|
});
|
||||||
|
// TODO: Replace this.
|
||||||
|
if (currentCharacter == "pico") dj.visible = false;
|
||||||
add(dj);
|
add(dj);
|
||||||
|
|
||||||
var bgDad:FlxSprite = new FlxSprite(pinkBack.width * 0.75, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad'));
|
var bgDad:FlxSprite = new FlxSprite(pinkBack.width * 0.75, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad'));
|
||||||
|
@ -859,8 +870,11 @@ class FreeplayState extends MusicBeatSubState
|
||||||
// TODO: DEBUG REMOVE THIS
|
// TODO: DEBUG REMOVE THIS
|
||||||
if (FlxG.keys.justPressed.P)
|
if (FlxG.keys.justPressed.P)
|
||||||
{
|
{
|
||||||
currentCharacter = (currentCharacter == "bf") ? "pico" : "bf";
|
var newParams:FreeplayStateParams =
|
||||||
changeSelection(0);
|
{
|
||||||
|
character: currentCharacter == "bf" ? "pico" : "bf",
|
||||||
|
};
|
||||||
|
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.freeplay.FreeplayState(newParams, sticker)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controls.BACK && !typing.hasFocus)
|
if (controls.BACK && !typing.hasFocus)
|
||||||
|
@ -914,7 +928,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FlxG.switchState(new MainMenuState());
|
FlxG.switchState(() -> new MainMenuState());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1080,13 +1094,7 @@ class FreeplayState extends MusicBeatSubState
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var targetDifficulty:String = currentDifficulty;
|
var targetDifficulty:String = currentDifficulty;
|
||||||
|
var targetVariation:String = targetSong.getFirstValidVariation(targetDifficulty);
|
||||||
// TODO: Implement Pico into the interface properly.
|
|
||||||
var targetCharacter:String = 'bf';
|
|
||||||
if (FlxG.keys.pressed.P)
|
|
||||||
{
|
|
||||||
targetCharacter = 'pico';
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayStatePlaylist.campaignId = cap.songData.levelId;
|
PlayStatePlaylist.campaignId = cap.songData.levelId;
|
||||||
|
|
||||||
|
@ -1100,11 +1108,11 @@ class FreeplayState extends MusicBeatSubState
|
||||||
|
|
||||||
new FlxTimer().start(1, function(tmr:FlxTimer) {
|
new FlxTimer().start(1, function(tmr:FlxTimer) {
|
||||||
Paths.setCurrentLevel(cap.songData.levelId);
|
Paths.setCurrentLevel(cap.songData.levelId);
|
||||||
LoadingState.loadAndSwitchState(new PlayState(
|
LoadingState.loadAndSwitchState(() -> new PlayState(
|
||||||
{
|
{
|
||||||
targetSong: targetSong,
|
targetSong: targetSong,
|
||||||
targetDifficulty: targetDifficulty,
|
targetDifficulty: targetDifficulty,
|
||||||
targetCharacter: targetCharacter,
|
targetVariation: targetVariation,
|
||||||
}), true);
|
}), true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1269,31 +1277,33 @@ class FreeplaySongData
|
||||||
public var songRating(default, null):Int = 0;
|
public var songRating(default, null):Int = 0;
|
||||||
|
|
||||||
public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
||||||
|
public var displayedVariations(default, null):Array<String> = [Constants.DEFAULT_VARIATION];
|
||||||
|
|
||||||
function set_currentDifficulty(value:String):String
|
function set_currentDifficulty(value:String):String
|
||||||
{
|
{
|
||||||
if (currentDifficulty == value) return value;
|
if (currentDifficulty == value) return value;
|
||||||
|
|
||||||
currentDifficulty = value;
|
currentDifficulty = value;
|
||||||
updateValues();
|
updateValues(displayedVariations);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function new(levelId:String, songId:String, song:Song)
|
public function new(levelId:String, songId:String, song:Song, ?displayedVariations:Array<String>)
|
||||||
{
|
{
|
||||||
this.levelId = levelId;
|
this.levelId = levelId;
|
||||||
this.songId = songId;
|
this.songId = songId;
|
||||||
this.song = song;
|
this.song = song;
|
||||||
|
if (displayedVariations != null) this.displayedVariations = displayedVariations;
|
||||||
|
|
||||||
updateValues();
|
updateValues(displayedVariations);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateValues():Void
|
function updateValues(displayedVariations:Array<String>):Void
|
||||||
{
|
{
|
||||||
this.songDifficulties = song.listDifficulties();
|
this.songDifficulties = song.listDifficulties(displayedVariations);
|
||||||
if (!this.songDifficulties.contains(currentDifficulty)) currentDifficulty = Constants.DEFAULT_DIFFICULTY;
|
if (!this.songDifficulties.contains(currentDifficulty)) currentDifficulty = Constants.DEFAULT_DIFFICULTY;
|
||||||
|
|
||||||
var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty);
|
var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, displayedVariations);
|
||||||
if (songDifficulty == null) return;
|
if (songDifficulty == null) return;
|
||||||
this.songName = songDifficulty.songName;
|
this.songName = songDifficulty.songName;
|
||||||
this.songCharacter = songDifficulty.characters.opponent;
|
this.songCharacter = songDifficulty.characters.opponent;
|
||||||
|
|
|
@ -150,7 +150,8 @@ class Level implements IRegistryEntry<LevelData>
|
||||||
|
|
||||||
if (firstSong != null)
|
if (firstSong != null)
|
||||||
{
|
{
|
||||||
for (difficulty in firstSong.listDifficulties())
|
// Don't display alternate characters in Story Mode.
|
||||||
|
for (difficulty in firstSong.listDifficulties([Constants.DEFAULT_VARIATION, "erect"]))
|
||||||
{
|
{
|
||||||
difficulties.push(difficulty);
|
difficulties.push(difficulty);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class StickerSubState extends MusicBeatSubState
|
||||||
* This is a FUNCTION so we can pass it directly to `FlxG.switchState()`,
|
* This is a FUNCTION so we can pass it directly to `FlxG.switchState()`,
|
||||||
* and we can add constructor parameters in the caller.
|
* and we can add constructor parameters in the caller.
|
||||||
*/
|
*/
|
||||||
var targetState:Void->FlxState;
|
var targetState:StickerSubState->FlxState;
|
||||||
|
|
||||||
// what "folders" to potentially load from (as of writing only "keys" exist)
|
// what "folders" to potentially load from (as of writing only "keys" exist)
|
||||||
var soundSelections:Array<String> = [];
|
var soundSelections:Array<String> = [];
|
||||||
|
@ -44,14 +44,11 @@ class StickerSubState extends MusicBeatSubState
|
||||||
var soundSelection:String = "";
|
var soundSelection:String = "";
|
||||||
var sounds:Array<String> = [];
|
var sounds:Array<String> = [];
|
||||||
|
|
||||||
public function new(?oldStickers:Array<StickerSprite>, ?targetState:Void->FlxState):Void
|
public function new(?oldStickers:Array<StickerSprite>, ?targetState:StickerSubState->FlxState):Void
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
if (targetState != null)
|
this.targetState = (targetState == null) ? ((sticker) -> new MainMenuState()) : targetState;
|
||||||
{
|
|
||||||
this.targetState = () -> new MainMenuState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo still
|
// todo still
|
||||||
// make sure that ONLY plays mp3/ogg files
|
// make sure that ONLY plays mp3/ogg files
|
||||||
|
@ -248,7 +245,7 @@ class StickerSubState extends MusicBeatSubState
|
||||||
dipshit.addChild(bitmap);
|
dipshit.addChild(bitmap);
|
||||||
FlxG.addChildBelowMouse(dipshit);
|
FlxG.addChildBelowMouse(dipshit);
|
||||||
|
|
||||||
FlxG.switchState(targetState);
|
FlxG.switchState(() -> targetState(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue