mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 03:13:45 +00:00
Rework Freeplay variation handling... again.
This commit is contained in:
parent
067f52ca91
commit
5630e74584
|
@ -34,7 +34,12 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
* The note style to use if this one doesn't have a certain asset.
|
||||
* This can be recursive, ehe.
|
||||
*/
|
||||
final fallback:Null<NoteStyle>;
|
||||
var fallback(get, never):Null<NoteStyle>;
|
||||
|
||||
function get_fallback():Null<NoteStyle> {
|
||||
if (_data == null || _data.fallback == null) return null;
|
||||
return NoteStyleRegistry.instance.fetchEntry(_data.fallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id The ID of the JSON file to parse.
|
||||
|
@ -43,9 +48,6 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
this.id = id;
|
||||
_data = _fetchData(id);
|
||||
|
||||
var fallbackID = _data.fallback;
|
||||
if (fallbackID != null) this.fallback = NoteStyleRegistry.instance.fetchEntry(fallbackID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +142,7 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
if (raw)
|
||||
{
|
||||
var rawPath:Null<String> = _data?.assets?.note?.assetPath;
|
||||
if (rawPath == null && fallback != null) return fallback.getNoteAssetPath(true);
|
||||
if (rawPath == null) return fallback?.getNoteAssetPath(true);
|
||||
return rawPath;
|
||||
}
|
||||
|
||||
|
@ -178,12 +180,13 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
|
||||
public function isNoteAnimated():Bool
|
||||
{
|
||||
return _data.assets?.note?.animated ?? false;
|
||||
// LOL is double ?? bad practice?
|
||||
return _data.assets?.note?.animated ?? fallback?.isNoteAnimated() ?? false;
|
||||
}
|
||||
|
||||
public function getNoteScale():Float
|
||||
{
|
||||
return _data.assets?.note?.scale ?? 1.0;
|
||||
return _data.assets?.note?.scale ?? fallback?.getNoteScale() ?? 1.0;
|
||||
}
|
||||
|
||||
function fetchNoteAnimationData(dir:NoteDirection):Null<AnimationData>
|
||||
|
@ -196,16 +199,15 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
case RIGHT: _data.assets?.note?.data?.right?.toNamed();
|
||||
};
|
||||
|
||||
return (result == null && fallback != null) ? fallback.fetchNoteAnimationData(dir) : result;
|
||||
return result ?? fallback?.fetchNoteAnimationData(dir);
|
||||
}
|
||||
|
||||
public function getHoldNoteAssetPath(raw:Bool = false):Null<String>
|
||||
{
|
||||
if (raw)
|
||||
{
|
||||
// TODO: figure out why ?. didn't work here
|
||||
var rawPath:Null<String> = (_data?.assets?.holdNote == null) ? null : _data?.assets?.holdNote?.assetPath;
|
||||
return (rawPath == null && fallback != null) ? fallback.getHoldNoteAssetPath(true) : rawPath;
|
||||
var rawPath:Null<String> = _data?.assets?.holdNote?.assetPath;
|
||||
return rawPath ?? fallback?.getHoldNoteAssetPath(true);
|
||||
}
|
||||
|
||||
// library:path
|
||||
|
@ -217,23 +219,17 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
|
||||
public function isHoldNotePixel():Bool
|
||||
{
|
||||
var data = _data?.assets?.holdNote;
|
||||
if (data == null && fallback != null) return fallback.isHoldNotePixel();
|
||||
return data?.isPixel ?? false;
|
||||
return _data?.assets?.holdNote?.isPixel ?? fallback?.isHoldNotePixel() ?? false;
|
||||
}
|
||||
|
||||
public function fetchHoldNoteScale():Float
|
||||
{
|
||||
var data = _data?.assets?.holdNote;
|
||||
if (data == null && fallback != null) return fallback.fetchHoldNoteScale();
|
||||
return data?.scale ?? 1.0;
|
||||
return _data?.assets?.holdNote?.scale ?? fallback?.fetchHoldNoteScale() ?? 1.0;
|
||||
}
|
||||
|
||||
public function getHoldNoteOffsets():Array<Float>
|
||||
{
|
||||
var data = _data?.assets?.holdNote;
|
||||
if (data == null && fallback != null) return fallback.getHoldNoteOffsets();
|
||||
return data?.offsets ?? [0.0, 0.0];
|
||||
return _data?.assets?.holdNote?.offsets ?? fallback?.getHoldNoteOffsets() ?? [0.0, 0.0];
|
||||
}
|
||||
|
||||
public function applyStrumlineFrames(target:StrumlineNote):Void
|
||||
|
@ -258,9 +254,7 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
if (raw)
|
||||
{
|
||||
var rawPath:Null<String> = _data?.assets?.noteStrumline?.assetPath;
|
||||
if (rawPath == null && fallback != null) return fallback.getStrumlineAssetPath(true);
|
||||
return rawPath;
|
||||
return _data?.assets?.noteStrumline?.assetPath ?? fallback?.getStrumlineAssetPath(true);
|
||||
}
|
||||
|
||||
// library:path
|
||||
|
@ -282,11 +276,19 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
FlxAnimationUtil.addAtlasAnimations(target, getStrumlineAnimationData(dir));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the animation data for the strumline.
|
||||
* NOTE: This function only queries the fallback note style if all the animations are missing for a given direction.
|
||||
*
|
||||
* @param dir The direction to fetch the animation data for.
|
||||
* @return The animation data for the strumline in that direction.
|
||||
*/
|
||||
function getStrumlineAnimationData(dir:NoteDirection):Array<AnimationData>
|
||||
{
|
||||
var result:Array<Null<AnimationData>> = switch (dir)
|
||||
{
|
||||
case NoteDirection.LEFT: [
|
||||
case NoteDirection.LEFT:
|
||||
[
|
||||
_data.assets.noteStrumline?.data?.leftStatic?.toNamed('static'),
|
||||
_data.assets.noteStrumline?.data?.leftPress?.toNamed('press'),
|
||||
_data.assets.noteStrumline?.data?.leftConfirm?.toNamed('confirm'),
|
||||
|
@ -313,14 +315,17 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
default: [];
|
||||
};
|
||||
|
||||
return thx.Arrays.filterNull(result);
|
||||
// New variable so we can change the type.
|
||||
var filteredResult:Array<AnimationData> = thx.Arrays.filterNull(result);
|
||||
|
||||
if (filteredResult.length == 0) return fallback?.getStrumlineAnimationData(dir) ?? [];
|
||||
|
||||
return filteredResult;
|
||||
}
|
||||
|
||||
public function getStrumlineOffsets():Array<Float>
|
||||
{
|
||||
var data = _data?.assets?.noteStrumline;
|
||||
if (data == null && fallback != null) return fallback.getStrumlineOffsets();
|
||||
return data?.offsets ?? [0.0, 0.0];
|
||||
return _data?.assets?.noteStrumline?.offsets ?? fallback?.getStrumlineOffsets() ?? [0.0, 0.0];
|
||||
}
|
||||
|
||||
public function applyStrumlineOffsets(target:StrumlineNote):Void
|
||||
|
@ -332,21 +337,17 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
|
||||
public function getStrumlineScale():Float
|
||||
{
|
||||
return _data?.assets?.noteStrumline?.scale ?? 1.0;
|
||||
return _data?.assets?.noteStrumline?.scale ?? fallback?.getStrumlineScale() ?? 1.0;
|
||||
}
|
||||
|
||||
public function isNoteSplashEnabled():Bool
|
||||
{
|
||||
var data = _data?.assets?.noteSplash?.data;
|
||||
if (data == null) return fallback?.isNoteSplashEnabled() ?? false;
|
||||
return data.enabled ?? false;
|
||||
return _data?.assets?.noteSplash?.data?.enabled ?? fallback?.isNoteSplashEnabled() ?? false;
|
||||
}
|
||||
|
||||
public function isHoldNoteCoverEnabled():Bool
|
||||
{
|
||||
var data = _data?.assets?.holdNoteCover?.data;
|
||||
if (data == null) return fallback?.isHoldNoteCoverEnabled() ?? false;
|
||||
return data.enabled ?? false;
|
||||
return _data?.assets?.holdNoteCover?.data?.enabled ?? fallback?.isHoldNoteCoverEnabled() ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -457,20 +458,20 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
case THREE:
|
||||
var result = _data.assets.countdownThree?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false;
|
||||
return result;
|
||||
case TWO:
|
||||
var result = _data.assets.countdownTwo?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false;
|
||||
return result;
|
||||
case ONE:
|
||||
var result = _data.assets.countdownOne?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false;
|
||||
return result;
|
||||
case GO:
|
||||
var result = _data.assets.countdownGo?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false;
|
||||
return result;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -482,20 +483,20 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
case THREE:
|
||||
var result = _data.assets.countdownThree?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0];
|
||||
return result;
|
||||
case TWO:
|
||||
var result = _data.assets.countdownTwo?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0];
|
||||
return result;
|
||||
case ONE:
|
||||
var result = _data.assets.countdownOne?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0];
|
||||
return result;
|
||||
case GO:
|
||||
var result = _data.assets.countdownGo?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0];
|
||||
return result;
|
||||
default:
|
||||
return [0, 0];
|
||||
}
|
||||
|
@ -520,7 +521,7 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
null;
|
||||
}
|
||||
|
||||
return (rawPath == null && fallback != null) ? fallback.getCountdownSoundPath(step, true) : rawPath;
|
||||
return (rawPath == null) ? fallback?.getCountdownSoundPath(step, true) : rawPath;
|
||||
}
|
||||
|
||||
// library:path
|
||||
|
@ -584,20 +585,20 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
case "sick":
|
||||
var result = _data.assets.judgementSick?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false;
|
||||
return result;
|
||||
case "good":
|
||||
var result = _data.assets.judgementGood?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false;
|
||||
return result;
|
||||
case "bad":
|
||||
var result = _data.assets.judgementBad?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false;
|
||||
return result;
|
||||
case "shit":
|
||||
var result = _data.assets.judgementShit?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false;
|
||||
return result;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -635,20 +636,20 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
case "sick":
|
||||
var result = _data.assets.judgementSick?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0];
|
||||
return result;
|
||||
case "good":
|
||||
var result = _data.assets.judgementGood?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0];
|
||||
return result;
|
||||
case "bad":
|
||||
var result = _data.assets.judgementBad?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0];
|
||||
return result;
|
||||
case "shit":
|
||||
var result = _data.assets.judgementShit?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0];
|
||||
return result;
|
||||
default:
|
||||
return [0, 0];
|
||||
}
|
||||
|
@ -749,44 +750,44 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
case 0:
|
||||
var result = _data.assets.comboNumber0?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 1:
|
||||
var result = _data.assets.comboNumber1?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 2:
|
||||
var result = _data.assets.comboNumber2?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 3:
|
||||
var result = _data.assets.comboNumber3?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 4:
|
||||
var result = _data.assets.comboNumber4?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 5:
|
||||
var result = _data.assets.comboNumber5?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 6:
|
||||
var result = _data.assets.comboNumber6?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 7:
|
||||
var result = _data.assets.comboNumber7?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 8:
|
||||
var result = _data.assets.comboNumber8?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
case 9:
|
||||
var result = _data.assets.comboNumber9?.isPixel;
|
||||
if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit);
|
||||
return result ?? false;
|
||||
if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false;
|
||||
return result;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -836,44 +837,44 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
|||
{
|
||||
case 0:
|
||||
var result = _data.assets.comboNumber0?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 1:
|
||||
var result = _data.assets.comboNumber1?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 2:
|
||||
var result = _data.assets.comboNumber2?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 3:
|
||||
var result = _data.assets.comboNumber3?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 4:
|
||||
var result = _data.assets.comboNumber4?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 5:
|
||||
var result = _data.assets.comboNumber5?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 6:
|
||||
var result = _data.assets.comboNumber6?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 7:
|
||||
var result = _data.assets.comboNumber7?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 8:
|
||||
var result = _data.assets.comboNumber8?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
case 9:
|
||||
var result = _data.assets.comboNumber9?.offsets;
|
||||
if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit);
|
||||
return result ?? [0, 0];
|
||||
if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0];
|
||||
return result;
|
||||
default:
|
||||
return [0, 0];
|
||||
}
|
||||
|
|
|
@ -144,11 +144,37 @@ class FreeplayState extends MusicBeatSubState
|
|||
|
||||
var songs:Array<Null<FreeplaySongData>> = [];
|
||||
|
||||
// List of available difficulties for the current song, without `-variation` at the end (no duplicates or nulls).
|
||||
var diffIdsCurrent:Array<String> = [];
|
||||
// List of available difficulties for the total song list, without `-variation` at the end (no duplicates or nulls).
|
||||
var diffIdsTotal:Array<String> = [];
|
||||
// List of available difficulties for the current song, with `-variation` at the end (no duplicates or nulls).
|
||||
var suffixedDiffIdsCurrent:Array<String> = [];
|
||||
// List of available difficulties for the total song list, with `-variation` at the end (no duplicates or nulls).
|
||||
var suffixedDiffIdsTotal:Array<String> = [];
|
||||
|
||||
var curSelected:Int = 0;
|
||||
var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
||||
var currentSuffixedDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
||||
var currentUnsuffixedDifficulty(get, never):String;
|
||||
|
||||
function get_currentUnsuffixedDifficulty():String
|
||||
{
|
||||
if (Constants.DEFAULT_DIFFICULTY_LIST_FULL.contains(currentSuffixedDifficulty)) return currentSuffixedDifficulty;
|
||||
|
||||
// Else, we need to strip the suffix.
|
||||
return currentSuffixedDifficulty.substring(0, currentSuffixedDifficulty.lastIndexOf('-'));
|
||||
}
|
||||
|
||||
var currentVariation(get, never):String;
|
||||
|
||||
function get_currentVariation():String
|
||||
{
|
||||
if (Constants.DEFAULT_DIFFICULTY_LIST.contains(currentSuffixedDifficulty)) return Constants.DEFAULT_VARIATION;
|
||||
if (Constants.DEFAULT_DIFFICULTY_LIST_ERECT.contains(currentSuffixedDifficulty)) return 'erect';
|
||||
|
||||
// Else, we need to isolate the suffix.
|
||||
return currentSuffixedDifficulty.substring(currentSuffixedDifficulty.lastIndexOf('-') + 1, currentSuffixedDifficulty.length);
|
||||
}
|
||||
|
||||
public var fp:FreeplayScore;
|
||||
|
||||
|
@ -356,11 +382,15 @@ class FreeplayState extends MusicBeatSubState
|
|||
trace('Available Difficulties: $availableDifficultiesForSong');
|
||||
if (availableDifficultiesForSong.length == 0) continue;
|
||||
|
||||
songs.push(new FreeplaySongData(levelId, songId, song, displayedVariations));
|
||||
songs.push(new FreeplaySongData(levelId, songId, song, currentCharacter, displayedVariations));
|
||||
for (difficulty in unsuffixedDifficulties)
|
||||
{
|
||||
diffIdsTotal.pushUnique(difficulty);
|
||||
}
|
||||
for (difficulty in availableDifficultiesForSong)
|
||||
{
|
||||
suffixedDiffIdsTotal.pushUnique(difficulty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +483,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
wait: 0.1
|
||||
});
|
||||
|
||||
for (diffId in diffIdsTotal)
|
||||
for (diffId in suffixedDiffIdsTotal)
|
||||
{
|
||||
var diffSprite:DifficultySprite = new DifficultySprite(diffId);
|
||||
diffSprite.difficultyId = diffId;
|
||||
|
@ -467,7 +497,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
for (diffSprite in grpDifficulties.group.members)
|
||||
{
|
||||
if (diffSprite == null) continue;
|
||||
if (diffSprite.difficultyId == currentDifficulty) diffSprite.visible = true;
|
||||
if (diffSprite.difficultyId == currentSuffixedDifficulty) diffSprite.visible = true;
|
||||
}
|
||||
|
||||
albumRoll.albumId = null;
|
||||
|
@ -743,17 +773,14 @@ class FreeplayState extends MusicBeatSubState
|
|||
{
|
||||
var tempSongs:Array<Null<FreeplaySongData>> = songs;
|
||||
|
||||
// Remember just the difficulty because it's important for song sorting.
|
||||
currentDifficulty = rememberedDifficulty;
|
||||
|
||||
if (filterStuff != null) tempSongs = sortSongs(tempSongs, filterStuff);
|
||||
|
||||
// Filter further by current selected difficulty.
|
||||
if (currentDifficulty != null)
|
||||
if (currentSuffixedDifficulty != null)
|
||||
{
|
||||
tempSongs = tempSongs.filter(song -> {
|
||||
if (song == null) return true; // Random
|
||||
return song.songDifficulties.contains(currentDifficulty);
|
||||
return song.suffixedSongDifficulties.contains(currentSuffixedDifficulty);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1371,6 @@ class FreeplayState extends MusicBeatSubState
|
|||
var dyTouch:Float = 0;
|
||||
var velTouch:Float = 0;
|
||||
|
||||
var veloctiyLoopShit:Float = 0;
|
||||
var touchTimer:Float = 0;
|
||||
|
||||
var initTouchPos:FlxPoint = new FlxPoint();
|
||||
|
@ -1756,16 +1782,18 @@ class FreeplayState extends MusicBeatSubState
|
|||
{
|
||||
touchTimer = 0;
|
||||
|
||||
var currentDifficultyIndex:Int = diffIdsCurrent.indexOf(currentDifficulty);
|
||||
var currentDifficultyIndex:Int = suffixedDiffIdsCurrent.indexOf(currentSuffixedDifficulty);
|
||||
|
||||
if (currentDifficultyIndex == -1) currentDifficultyIndex = diffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY);
|
||||
if (currentDifficultyIndex == -1) currentDifficultyIndex = suffixedDiffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY);
|
||||
|
||||
currentDifficultyIndex += change;
|
||||
|
||||
if (currentDifficultyIndex < 0) currentDifficultyIndex = diffIdsCurrent.length - 1;
|
||||
if (currentDifficultyIndex >= diffIdsCurrent.length) currentDifficultyIndex = 0;
|
||||
if (currentDifficultyIndex < 0) currentDifficultyIndex = suffixedDiffIdsCurrent.length - 1;
|
||||
if (currentDifficultyIndex >= suffixedDiffIdsCurrent.length) currentDifficultyIndex = 0;
|
||||
|
||||
currentDifficulty = diffIdsCurrent[currentDifficultyIndex];
|
||||
currentSuffixedDifficulty = suffixedDiffIdsCurrent[currentDifficultyIndex];
|
||||
|
||||
trace('Switching to difficulty: ${currentSuffixedDifficulty}');
|
||||
|
||||
var daSong:Null<FreeplaySongData> = grpCapsules.members[curSelected].songData;
|
||||
if (daSong != null)
|
||||
|
@ -1776,22 +1804,20 @@ class FreeplayState extends MusicBeatSubState
|
|||
FlxG.log.warn('WARN: could not find song with id (${daSong.songId})');
|
||||
return;
|
||||
}
|
||||
var targetVariation:String = targetSong.getFirstValidVariation(currentDifficulty, currentCharacter) ?? '';
|
||||
|
||||
// TODO: This line of code makes me sad, but you can't really fix it without a breaking migration.
|
||||
var suffixedDifficulty = (targetVariation != Constants.DEFAULT_VARIATION
|
||||
&& targetVariation != 'erect') ? '$currentDifficulty-${targetVariation}' : currentDifficulty;
|
||||
var suffixedDifficulty = suffixedDiffIdsCurrent[currentDifficultyIndex];
|
||||
var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSong.songId, suffixedDifficulty);
|
||||
trace(songScore);
|
||||
intendedScore = songScore?.score ?? 0;
|
||||
intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
|
||||
rememberedDifficulty = suffixedDifficulty;
|
||||
currentSuffixedDifficulty = suffixedDifficulty;
|
||||
}
|
||||
else
|
||||
{
|
||||
intendedScore = 0;
|
||||
intendedCompletion = 0.0;
|
||||
rememberedDifficulty = currentDifficulty;
|
||||
rememberedDifficulty = currentSuffixedDifficulty;
|
||||
}
|
||||
|
||||
if (intendedCompletion == Math.POSITIVE_INFINITY || intendedCompletion == Math.NEGATIVE_INFINITY || Math.isNaN(intendedCompletion))
|
||||
|
@ -1806,7 +1832,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
for (diffSprite in grpDifficulties.group.members)
|
||||
{
|
||||
if (diffSprite == null) continue;
|
||||
if (diffSprite.difficultyId == currentDifficulty)
|
||||
if (diffSprite.difficultyId == currentSuffixedDifficulty)
|
||||
{
|
||||
if (change != 0)
|
||||
{
|
||||
|
@ -1833,7 +1859,9 @@ class FreeplayState extends MusicBeatSubState
|
|||
if (songCapsule == null) continue;
|
||||
if (songCapsule.songData != null)
|
||||
{
|
||||
songCapsule.songData.currentDifficulty = currentDifficulty;
|
||||
songCapsule.songData.currentVariation = currentVariation;
|
||||
songCapsule.songData.currentUnsuffixedDifficulty = currentUnsuffixedDifficulty;
|
||||
songCapsule.songData.currentSuffixedDifficulty = currentSuffixedDifficulty;
|
||||
songCapsule.init(null, null, songCapsule.songData);
|
||||
songCapsule.checkClip();
|
||||
}
|
||||
|
@ -1921,8 +1949,9 @@ class FreeplayState extends MusicBeatSubState
|
|||
return;
|
||||
}
|
||||
var targetSong:Song = targetSongNullable;
|
||||
var targetDifficultyId:String = currentDifficulty;
|
||||
var targetVariation:Null<String> = targetSong.getFirstValidVariation(targetDifficultyId, currentCharacter);
|
||||
var targetDifficultyId:String = currentUnsuffixedDifficulty;
|
||||
var targetVariation:Null<String> = currentVariation;
|
||||
trace('target song: ${targetSongId} (${targetVariation})');
|
||||
var targetLevelId:Null<String> = cap?.songData?.levelId;
|
||||
PlayStatePlaylist.campaignId = targetLevelId ?? null;
|
||||
|
||||
|
@ -2002,8 +2031,8 @@ class FreeplayState extends MusicBeatSubState
|
|||
return;
|
||||
}
|
||||
var targetSong:Song = targetSongNullable;
|
||||
var targetDifficultyId:String = currentDifficulty;
|
||||
var targetVariation:Null<String> = targetSong.getFirstValidVariation(targetDifficultyId, currentCharacter);
|
||||
var targetDifficultyId:String = currentUnsuffixedDifficulty;
|
||||
var targetVariation:Null<String> = currentVariation;
|
||||
var targetLevelId:Null<String> = cap?.songData?.levelId;
|
||||
PlayStatePlaylist.campaignId = targetLevelId ?? null;
|
||||
|
||||
|
@ -2069,7 +2098,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
|
||||
if (rememberedDifficulty != null)
|
||||
{
|
||||
currentDifficulty = rememberedDifficulty;
|
||||
currentSuffixedDifficulty = rememberedDifficulty;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2087,10 +2116,11 @@ class FreeplayState extends MusicBeatSubState
|
|||
var daSongCapsule:SongMenuItem = grpCapsules.members[curSelected];
|
||||
if (daSongCapsule.songData != null)
|
||||
{
|
||||
var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty);
|
||||
var songScore:Null<SaveScoreData> = Save.instance.getSongScore(daSongCapsule.songData.songId, currentSuffixedDifficulty);
|
||||
intendedScore = songScore?.score ?? 0;
|
||||
intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
|
||||
diffIdsCurrent = daSongCapsule.songData.songDifficulties;
|
||||
suffixedDiffIdsCurrent = daSongCapsule.songData.suffixedSongDifficulties;
|
||||
rememberedSongId = daSongCapsule.songData.songId;
|
||||
changeDiff();
|
||||
}
|
||||
|
@ -2099,6 +2129,7 @@ class FreeplayState extends MusicBeatSubState
|
|||
intendedScore = 0;
|
||||
intendedCompletion = 0.0;
|
||||
diffIdsCurrent = diffIdsTotal;
|
||||
suffixedDiffIdsCurrent = suffixedDiffIdsTotal;
|
||||
rememberedSongId = null;
|
||||
rememberedDifficulty = Constants.DEFAULT_DIFFICULTY;
|
||||
albumRoll.albumId = null;
|
||||
|
@ -2143,17 +2174,18 @@ class FreeplayState extends MusicBeatSubState
|
|||
if (previewSongId == null) return;
|
||||
|
||||
var previewSong:Null<Song> = SongRegistry.instance.fetchEntry(previewSongId);
|
||||
var currentVariation = previewSong?.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST;
|
||||
var songDifficulty:Null<SongDifficulty> = previewSong?.getDifficulty(currentDifficulty,
|
||||
previewSong?.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST);
|
||||
if (previewSong == null) return;
|
||||
// var currentVariation = previewSong.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST;
|
||||
var targetDifficultyId:String = currentUnsuffixedDifficulty;
|
||||
var targetVariation:Null<String> = currentVariation;
|
||||
var songDifficulty:Null<SongDifficulty> = previewSong.getDifficulty(targetDifficultyId, targetVariation ?? Constants.DEFAULT_VARIATION);
|
||||
|
||||
var baseInstrumentalId:String = previewSong?.getBaseInstrumentalId(currentDifficulty, songDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? '';
|
||||
var altInstrumentalIds:Array<String> = previewSong?.listAltInstrumentalIds(currentDifficulty,
|
||||
var baseInstrumentalId:String = previewSong.getBaseInstrumentalId(targetDifficultyId, songDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? '';
|
||||
var altInstrumentalIds:Array<String> = previewSong.listAltInstrumentalIds(targetDifficultyId,
|
||||
songDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? [];
|
||||
|
||||
var instSuffix:String = baseInstrumentalId;
|
||||
|
||||
// TODO: Make this a UI element.
|
||||
#if FEATURE_DEBUG_FUNCTIONS
|
||||
if (altInstrumentalIds.length > 0 && FlxG.keys.pressed.CONTROL)
|
||||
{
|
||||
|
@ -2312,6 +2344,7 @@ class FreeplaySongData
|
|||
public var songId(default, null):String = '';
|
||||
|
||||
public var songDifficulties(default, null):Array<String> = [];
|
||||
public var suffixedSongDifficulties(default, null):Array<String> = [];
|
||||
|
||||
public var songName(default, null):String = '';
|
||||
public var songCharacter(default, null):String = '';
|
||||
|
@ -2319,22 +2352,25 @@ class FreeplaySongData
|
|||
public var difficultyRating(default, null):Int = 0;
|
||||
public var albumId(default, null):Null<String> = null;
|
||||
|
||||
public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
||||
public var currentCharacter:PlayableCharacter;
|
||||
public var currentVariation:String = Constants.DEFAULT_VARIATION;
|
||||
public var currentSuffixedDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
||||
public var currentUnsuffixedDifficulty:String = Constants.DEFAULT_DIFFICULTY;
|
||||
|
||||
public var scoringRank:Null<ScoringRank> = null;
|
||||
|
||||
var displayedVariations:Array<String> = [Constants.DEFAULT_VARIATION];
|
||||
|
||||
function set_currentDifficulty(value:String):String
|
||||
function set_currentSuffixedDifficulty(value:String):String
|
||||
{
|
||||
if (currentDifficulty == value) return value;
|
||||
if (currentSuffixedDifficulty == value) return value;
|
||||
|
||||
currentDifficulty = value;
|
||||
currentSuffixedDifficulty = value;
|
||||
updateValues(displayedVariations);
|
||||
return value;
|
||||
}
|
||||
|
||||
public function new(levelId:String, songId:String, song:Song, ?displayedVariations:Array<String>)
|
||||
public function new(levelId:String, songId:String, song:Song, currentCharacter:PlayableCharacter, ?displayedVariations:Array<String>)
|
||||
{
|
||||
this.levelId = levelId;
|
||||
this.songId = songId;
|
||||
|
@ -2342,6 +2378,7 @@ class FreeplaySongData
|
|||
|
||||
this.isFav = Save.instance.isSongFavorited(songId);
|
||||
|
||||
this.currentCharacter = currentCharacter;
|
||||
if (displayedVariations != null) this.displayedVariations = displayedVariations;
|
||||
|
||||
updateValues(displayedVariations);
|
||||
|
@ -2368,15 +2405,18 @@ class FreeplaySongData
|
|||
function updateValues(variations:Array<String>):Void
|
||||
{
|
||||
this.songDifficulties = song.listDifficulties(null, variations, false, false);
|
||||
if (!this.songDifficulties.contains(currentDifficulty))
|
||||
this.suffixedSongDifficulties = song.listSuffixedDifficulties(variations, false, false);
|
||||
if (!this.songDifficulties.contains(currentUnsuffixedDifficulty))
|
||||
{
|
||||
currentDifficulty = Constants.DEFAULT_DIFFICULTY;
|
||||
currentSuffixedDifficulty = Constants.DEFAULT_DIFFICULTY;
|
||||
// This method gets called again by the setter-method
|
||||
// or the difficulty didn't change, so there's no need to continue.
|
||||
return;
|
||||
}
|
||||
|
||||
var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, null, variations);
|
||||
var targetVariation:Null<String> = currentVariation;
|
||||
|
||||
var songDifficulty:SongDifficulty = song.getDifficulty(currentUnsuffixedDifficulty, targetVariation);
|
||||
if (songDifficulty == null) return;
|
||||
this.songStartingBpm = songDifficulty.getStartingBPM();
|
||||
this.songName = songDifficulty.songName;
|
||||
|
@ -2392,10 +2432,7 @@ class FreeplaySongData
|
|||
this.albumId = songDifficulty.album;
|
||||
}
|
||||
|
||||
// TODO: This line of code makes me sad, but you can't really fix it without a breaking migration.
|
||||
// `easy`, `erect`, `normal-pico`, etc.
|
||||
var suffixedDifficulty = (songDifficulty.variation != Constants.DEFAULT_VARIATION
|
||||
&& songDifficulty.variation != 'erect') ? '$currentDifficulty-${songDifficulty.variation}' : currentDifficulty;
|
||||
var suffixedDifficulty = currentSuffixedDifficulty;
|
||||
|
||||
this.scoringRank = Save.instance.getSongRank(songId, suffixedDifficulty);
|
||||
|
||||
|
|
|
@ -186,6 +186,11 @@ class Constants
|
|||
*/
|
||||
public static final DEFAULT_DIFFICULTY_LIST:Array<String> = ['easy', 'normal', 'hard'];
|
||||
|
||||
/**
|
||||
* Default list of difficulties for Erect mode.
|
||||
*/
|
||||
public static final DEFAULT_DIFFICULTY_LIST_ERECT:Array<String> = ['erect', 'nightmare'];
|
||||
|
||||
/**
|
||||
* List of all difficulties used by the base game.
|
||||
* Includes Erect and Nightmare.
|
||||
|
|
Loading…
Reference in a new issue