Merge branch 'rewrite/master' into pursnake/character-scale

This commit is contained in:
EliteMasterEric 2024-05-30 23:40:00 -04:00
commit 573e1575a7
54 changed files with 2334 additions and 585 deletions

4
.gitmodules vendored
View file

@ -1,6 +1,6 @@
[submodule "assets"] [submodule "assets"]
path = assets path = assets
url = https://github.com/FunkinCrew/funkin.assets url = https://github.com/FunkinCrew/Funkin-assets-secret
[submodule "art"] [submodule "art"]
path = art path = art
url = https://github.com/FunkinCrew/funkin.art url = https://github.com/FunkinCrew/Funkin-art-secret

6
.vscode/launch.json vendored
View file

@ -3,13 +3,13 @@
"configurations": [ "configurations": [
{ {
// Launch in native/CPP on Windows/OSX/Linux // Launch in native/CPP on Windows/OSX/Linux
"name": "Lime", "name": "Lime Build+Debug",
"type": "lime", "type": "lime",
"request": "launch" "request": "launch"
}, },
{ {
// Launch in native/CPP on Windows/OSX/Linux (without compiling) // Launch in native/CPP on Windows/OSX/Linux
"name": "Debug", "name": "Lime Debug (No Build)",
"type": "lime", "type": "lime",
"request": "launch", "request": "launch",
"preLaunchTask": null "preLaunchTask": null

View file

@ -155,6 +155,11 @@
"target": "hl", "target": "hl",
"args": ["-debug", "-DDIALOGUE"] "args": ["-debug", "-DDIALOGUE"]
}, },
{
"label": "Windows / Debug (Results Screen Test)",
"target": "windows",
"args": ["-debug", "-DRESULTS"]
},
{ {
"label": "Windows / Debug (Straight to Chart Editor)", "label": "Windows / Debug (Straight to Chart Editor)",
"target": "windows", "target": "windows",

View file

@ -4,6 +4,28 @@ All notable changes will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.4.0] - 2024-05-??
### Added
- 2 new Erect remixes, Eggnog and Satin Panties. Check them out from
- Improvements to the Freeplay screen, with song difficulty ratings and player rank displays.
- Reworked the Results screen, with additional animations and audio based on your performance.
- Added a Charter field to the chart format, to allow for crediting the creator of a level's chart.
- You can see who charted a song from the Pause menu.
### Changed
- Tweaked the charts for several songs:
- Winter Horrorland
- Stress
- Lit Up
- Custom note styles are now properly supported for songs; add new notestyles via JSON, then select it for use from the Chart Editor Metadata toolbox. (thanks Keoiki!)
- Health icons now support a Winning frame without requiring a spritesheet, simply include a third frame in the icon file. (thanks gamerbross!)
- Remember that for more complex behaviors such as animations or transitions, you should use an XML file to define each frame.
### Fixed
- Fixed a bug where pressing the volume keys would stop the Toy commercial (thanks gamerbross!)
- Fixed a bug where the Chart Editor would crash when losing (thanks gamerbross!)
- Made improvements to compiling documentation (thanks gedehari!)
- Fixed a crash on Linux caused by an old version of hxCodec (thanks Noobz4Life!)
- Optimized animation handling for characters (thanks richTrash21!)
## [0.3.3] - 2024-05-14 ## [0.3.3] - 2024-05-14
### Changed ### Changed
- Cleaned up some code in `PlayAnimationSongEvent.hx` (thanks BurgerBalls!) - Cleaned up some code in `PlayAnimationSongEvent.hx` (thanks BurgerBalls!)

View file

@ -128,6 +128,7 @@
<haxelib name="json2object" /> <!-- JSON parsing --> <haxelib name="json2object" /> <!-- JSON parsing -->
<haxelib name="thx.core" /> <!-- General utility library, "the lodash of Haxe" -->
<haxelib name="thx.semver" /> <!-- Version string handling --> <haxelib name="thx.semver" /> <!-- Version string handling -->
<haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support --> <haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support -->

View file

@ -23,7 +23,7 @@ Full credits can be found in-game, or wherever the credits.json file is.
## Programming ## Programming
- [ninjamuffin99](https://twitter.com/ninja_muffin99) - Lead Programmer - [ninjamuffin99](https://twitter.com/ninja_muffin99) - Lead Programmer
- [MasterEric](https://twitter.com/EliteMasterEric) - Programmer - [EliteMasterEric](https://twitter.com/EliteMasterEric) - Programmer
- [MtH](https://twitter.com/emmnyaa) - Charting and Additional Programming - [MtH](https://twitter.com/emmnyaa) - Charting and Additional Programming
- [GeoKureli](https://twitter.com/Geokureli/) - Additional Programming - [GeoKureli](https://twitter.com/Geokureli/) - Additional Programming
- Our contributors on GitHub - Our contributors on GitHub

2
assets

@ -1 +1 @@
Subproject commit 783f22e741c85223da7f3f815b28fc4c6f240cbc Subproject commit 8fea0bf1fe07b6dd0efb8ecf46dc8091b0177007

View file

@ -3,7 +3,7 @@
"description": "An introductory mod.", "description": "An introductory mod.",
"contributors": [ "contributors": [
{ {
"name": "MasterEric" "name": "EliteMasterEric"
} }
], ],
"api_version": "0.1.0", "api_version": "0.1.0",

View file

@ -3,7 +3,7 @@
"description": "Newgrounds? More like OLDGROUNDS lol.", "description": "Newgrounds? More like OLDGROUNDS lol.",
"contributors": [ "contributors": [
{ {
"name": "MasterEric" "name": "EliteMasterEric"
} }
], ],
"api_version": "0.1.0", "api_version": "0.1.0",

View file

@ -153,7 +153,7 @@
"name": "polymod", "name": "polymod",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "8553b800965f225bb14c7ab8f04bfa9cdec362ac", "ref": "bfbe30d81601b3543d80dce580108ad6b7e182c7",
"url": "https://github.com/larsiusprime/polymod" "url": "https://github.com/larsiusprime/polymod"
}, },
{ {

View file

@ -214,6 +214,30 @@ class InitState extends FlxState
#elseif STAGEBUILD #elseif STAGEBUILD
// -DSTAGEBUILD // -DSTAGEBUILD
FlxG.switchState(() -> new funkin.ui.debug.stage.StageBuilderState()); FlxG.switchState(() -> new funkin.ui.debug.stage.StageBuilderState());
#elseif RESULTS
// -DRESULTS
FlxG.switchState(() -> new funkin.play.ResultState(
{
storyMode: false,
title: "CUM SONG",
isNewHighscore: true,
scoreData:
{
score: 1_234_567,
tallies:
{
sick: 130,
good: 25,
bad: 69,
shit: 69,
missed: 69,
combo: 69,
maxCombo: 69,
totalNotesHit: 140,
totalNotes: 200 // 0,
}
},
}));
#elseif ANIMDEBUG #elseif ANIMDEBUG
// -DANIMDEBUG // -DANIMDEBUG
FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState()); FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState());

View file

@ -1,9 +1,5 @@
package funkin.api.newgrounds; package funkin.api.newgrounds;
import flixel.util.FlxSignal;
import flixel.util.FlxTimer;
import lime.app.Application;
import openfl.display.Stage;
#if newgrounds #if newgrounds
import io.newgrounds.NG; import io.newgrounds.NG;
import io.newgrounds.NGLite; import io.newgrounds.NGLite;

View file

@ -2,19 +2,11 @@ package funkin.api.newgrounds;
#if newgrounds #if newgrounds
import flixel.util.FlxSignal; import flixel.util.FlxSignal;
import flixel.util.FlxTimer;
import io.newgrounds.NG; import io.newgrounds.NG;
import io.newgrounds.NGLite; import io.newgrounds.NGLite;
import io.newgrounds.components.ScoreBoardComponent.Period;
import io.newgrounds.objects.Error; import io.newgrounds.objects.Error;
import io.newgrounds.objects.Medal;
import io.newgrounds.objects.Score; import io.newgrounds.objects.Score;
import io.newgrounds.objects.ScoreBoard;
import io.newgrounds.objects.events.Response;
import io.newgrounds.objects.events.Result.GetCurrentVersionResult;
import io.newgrounds.objects.events.Result.GetVersionResult;
import lime.app.Application; import lime.app.Application;
import openfl.display.Stage;
#end #end
/** /**

View file

@ -11,10 +11,9 @@ import funkin.audio.waveform.WaveformDataParser;
import funkin.data.song.SongData.SongMusicData; import funkin.data.song.SongData.SongMusicData;
import funkin.data.song.SongRegistry; import funkin.data.song.SongRegistry;
import funkin.util.tools.ICloneable; import funkin.util.tools.ICloneable;
import openfl.Assets;
import openfl.media.SoundMixer; import openfl.media.SoundMixer;
#if (openfl >= "8.0.0") #if (openfl >= "8.0.0")
import openfl.utils.AssetType;
#end #end
/** /**

View file

@ -1,9 +1,7 @@
package funkin.audio; package funkin.audio;
import funkin.audio.FunkinSound;
import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup.FlxTypedGroup;
import funkin.audio.waveform.WaveformData; import funkin.audio.waveform.WaveformData;
import funkin.audio.waveform.WaveformDataParser;
class VoicesGroup extends SoundGroup class VoicesGroup extends SoundGroup
{ {

View file

@ -1,13 +1,9 @@
package funkin.audio.visualize; package funkin.audio.visualize;
import funkin.audio.visualize.dsp.FFT;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.addons.plugin.taskManager.FlxTask;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.math.FlxMath;
import flixel.sound.FlxSound; import flixel.sound.FlxSound;
import funkin.util.MathUtil;
import funkin.vis.dsp.SpectralAnalyzer; import funkin.vis.dsp.SpectralAnalyzer;
import funkin.vis.audioclip.frontends.LimeAudioClip; import funkin.vis.audioclip.frontends.LimeAudioClip;

View file

@ -1,6 +1,5 @@
package funkin.audio.visualize; package funkin.audio.visualize;
import funkin.audio.visualize.PolygonSpectogram;
import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.sound.FlxSound; import flixel.sound.FlxSound;

View file

@ -8,8 +8,6 @@ import flixel.sound.FlxSound;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import funkin.audio.visualize.PolygonSpectogram.VISTYPE; import funkin.audio.visualize.PolygonSpectogram.VISTYPE;
import funkin.audio.visualize.VisShit.CurAudioInfo; import funkin.audio.visualize.VisShit.CurAudioInfo;
import funkin.audio.visualize.dsp.FFT;
import lime.system.ThreadPool;
import lime.utils.Int16Array; import lime.utils.Int16Array;
using Lambda; using Lambda;
@ -38,8 +36,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
lengthOfShit = amnt; lengthOfShit = amnt;
regenLineShit(); regenLineShit();
// makeGraphic(200, 200, FlxColor.BLACK);
} }
public function regenLineShit():Void public function regenLineShit():Void
@ -89,8 +85,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
{ {
checkAndSetBuffer(); checkAndSetBuffer();
// vis.checkAndSetBuffer();
if (setBuffer) if (setBuffer)
{ {
var samplesToGen:Int = Std.int(sampleRate * seconds); var samplesToGen:Int = Std.int(sampleRate * seconds);
@ -191,7 +185,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
// a value between 10hz and 100Khz // a value between 10hz and 100Khz
var hzPicker:Float = Math.pow(10, powedShit); var hzPicker:Float = Math.pow(10, powedShit);
// var sampleApprox:Int = Std.int(FlxMath.remapToRange(i, 0, group.members.length, startingSample, startingSample + samplesToGen));
var remappedFreq:Int = Std.int(FlxMath.remapToRange(hzPicker, 0, 10000, 0, freqShit[0].length - 1)); var remappedFreq:Int = Std.int(FlxMath.remapToRange(hzPicker, 0, 10000, 0, freqShit[0].length - 1));
group.members[i].x = prevLine.x; group.members[i].x = prevLine.x;
@ -211,8 +204,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
var line = FlxPoint.get(prevLine.x - group.members[i].x, prevLine.y - group.members[i].y); var line = FlxPoint.get(prevLine.x - group.members[i].x, prevLine.y - group.members[i].y);
// dont draw a line until i figure out a nicer way to view da spikes and shit idk lol! // dont draw a line until i figure out a nicer way to view da spikes and shit idk lol!
// group.members[i].setGraphicSize(Std.int(Math.max(line.length, 1)), Std.int(1));
// group.members[i].angle = line.degrees;
} }
} }
} }
@ -261,9 +252,6 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
group.members[Std.int(remappedSample)].x = prevLine.x; group.members[Std.int(remappedSample)].x = prevLine.x;
group.members[Std.int(remappedSample)].y = prevLine.y; group.members[Std.int(remappedSample)].y = prevLine.y;
// group.members[0].y = prevLine.y;
// FlxSpriteUtil.drawLine(this, prevLine.x, prevLine.y, width * remappedSample, left * height / 2 + height / 2);
prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x; prevLine.x = (curAud.balanced * swagheight / 2 + swagheight / 2) + x;
prevLine.y = (Std.int(remappedSample) / lengthOfShit * daHeight) + y; prevLine.y = (Std.int(remappedSample) / lengthOfShit * daHeight) + y;

View file

@ -3,7 +3,6 @@ package funkin.audio.visualize;
import flixel.math.FlxMath; import flixel.math.FlxMath;
import flixel.sound.FlxSound; import flixel.sound.FlxSound;
import funkin.audio.visualize.dsp.FFT; import funkin.audio.visualize.dsp.FFT;
import lime.system.ThreadPool;
import lime.utils.Int16Array; import lime.utils.Int16Array;
import funkin.util.MathUtil; import funkin.util.MathUtil;
@ -73,9 +72,6 @@ class VisShit
freqOutput.push([]); freqOutput.push([]);
// if (FlxG.keys.justPressed.M)
// trace(FFT.rfft(chunk).map(z -> z.scale(1 / fs).magnitude));
// find spectral peaks and their instantaneous frequencies // find spectral peaks and their instantaneous frequencies
for (k => s in freqs) for (k => s in freqs)
{ {
@ -91,7 +87,6 @@ class VisShit
if (freq < maxFreq) freqOutput[indexOfArray].push(power); if (freq < maxFreq) freqOutput[indexOfArray].push(power);
// //
} }
// haxe.Log.trace("", null);
indexOfArray++; indexOfArray++;
// move to next (overlapping) chunk // move to next (overlapping) chunk

View file

@ -1,7 +1,5 @@
package funkin.audio.visualize.dsp; package funkin.audio.visualize.dsp;
import funkin.audio.visualize.dsp.Complex;
using funkin.audio.visualize.dsp.OffsetArray; using funkin.audio.visualize.dsp.OffsetArray;
using funkin.audio.visualize.dsp.Signal; using funkin.audio.visualize.dsp.Signal;

View file

@ -1,7 +1,5 @@
package funkin.audio.waveform; package funkin.audio.waveform;
import funkin.util.MathUtil;
@:nullSafety @:nullSafety
class WaveformData class WaveformData
{ {

View file

@ -1,7 +1,5 @@
package funkin.audio.waveform; package funkin.audio.waveform;
import funkin.audio.waveform.WaveformData;
import funkin.audio.waveform.WaveformDataParser;
import funkin.graphics.rendering.MeshRender; import funkin.graphics.rendering.MeshRender;
import flixel.util.FlxColor; import flixel.util.FlxColor;

View file

@ -1,7 +1,5 @@
package funkin.data.dialogue.conversation; package funkin.data.dialogue.conversation;
import funkin.data.animation.AnimationData;
/** /**
* A type definition for the data for a specific conversation. * A type definition for the data for a specific conversation.
* It includes things like what dialogue boxes to use, what text to display, and what animations to play. * It includes things like what dialogue boxes to use, what text to display, and what animations to play.

View file

@ -1,7 +1,6 @@
package funkin.data.dialogue.conversation; package funkin.data.dialogue.conversation;
import funkin.play.cutscene.dialogue.Conversation; import funkin.play.cutscene.dialogue.Conversation;
import funkin.data.dialogue.conversation.ConversationData;
import funkin.play.cutscene.dialogue.ScriptedConversation; import funkin.play.cutscene.dialogue.ScriptedConversation;
class ConversationRegistry extends BaseRegistry<Conversation, ConversationData> class ConversationRegistry extends BaseRegistry<Conversation, ConversationData>

View file

@ -0,0 +1,240 @@
package funkin.effects;
import flixel.FlxObject;
import flixel.util.FlxDestroyUtil.IFlxDestroyable;
import flixel.util.FlxPool;
import flixel.util.FlxTimer;
import flixel.math.FlxPoint;
import flixel.util.FlxAxes;
import flixel.tweens.FlxEase.EaseFunction;
import flixel.math.FlxMath;
/**
* pretty much a copy of FlxFlicker geared towards making sprites
* shake around at a set interval and slow down over time.
*/
class IntervalShake implements IFlxDestroyable
{
static var _pool:FlxPool<IntervalShake> = new FlxPool<IntervalShake>(IntervalShake.new);
/**
* Internal map for looking up which objects are currently shaking and getting their shake data.
*/
static var _boundObjects:Map<FlxObject, IntervalShake> = new Map<FlxObject, IntervalShake>();
/**
* An effect that shakes the sprite on a set interval and a starting intensity that goes down over time.
*
* @param Object The object to shake.
* @param Duration How long to shake for (in seconds). `0` means "forever".
* @param Interval In what interval to update the shake position. Set to `FlxG.elapsed` if `<= 0`!
* @param StartIntensity The starting intensity of the shake.
* @param EndIntensity The ending intensity of the shake.
* @param Ease Control the easing of the intensity over the shake.
* @param CompletionCallback Callback on shake completion
* @param ProgressCallback Callback on each shake interval
* @return The `IntervalShake` object. `IntervalShake`s are pooled internally, so beware of storing references.
*/
public static function shake(Object:FlxObject, Duration:Float = 1, Interval:Float = 0.04, StartIntensity:Float = 0, EndIntensity:Float = 0,
Ease:EaseFunction, ?CompletionCallback:IntervalShake->Void, ?ProgressCallback:IntervalShake->Void):IntervalShake
{
if (isShaking(Object))
{
// if (ForceRestart)
// {
// stopShaking(Object);
// }
// else
// {
// Ignore this call if object is already flickering.
return _boundObjects[Object];
// }
}
if (Interval <= 0)
{
Interval = FlxG.elapsed;
}
var shake:IntervalShake = _pool.get();
shake.start(Object, Duration, Interval, StartIntensity, EndIntensity, Ease, CompletionCallback, ProgressCallback);
return _boundObjects[Object] = shake;
}
/**
* Returns whether the object is shaking or not.
*
* @param Object The object to test.
*/
public static function isShaking(Object:FlxObject):Bool
{
return _boundObjects.exists(Object);
}
/**
* Stops shaking the object.
*
* @param Object The object to stop shaking.
*/
public static function stopShaking(Object:FlxObject):Void
{
var boundShake:IntervalShake = _boundObjects[Object];
if (boundShake != null)
{
boundShake.stop();
}
}
/**
* The shaking object.
*/
public var object(default, null):FlxObject;
/**
* The shaking timer. You can check how many seconds has passed since shaking started etc.
*/
public var timer(default, null):FlxTimer;
/**
* The starting intensity of the shake.
*/
public var startIntensity(default, null):Float;
/**
* The ending intensity of the shake.
*/
public var endIntensity(default, null):Float;
/**
* How long to shake for (in seconds). `0` means "forever".
*/
public var duration(default, null):Float;
/**
* The interval of the shake.
*/
public var interval(default, null):Float;
/**
* Defines on what axes to `shake()`. Default value is `XY` / both.
*/
public var axes(default, null):FlxAxes;
/**
* Defines the initial position of the object at the beginning of the shake effect.
*/
public var initialOffset(default, null):FlxPoint;
/**
* The callback that will be triggered after the shake has completed.
*/
public var completionCallback(default, null):IntervalShake->Void;
/**
* The callback that will be triggered every time the object shakes.
*/
public var progressCallback(default, null):IntervalShake->Void;
/**
* The easing of the intensity over the shake.
*/
public var ease(default, null):EaseFunction;
/**
* Nullifies the references to prepare object for reuse and avoid memory leaks.
*/
public function destroy():Void
{
object = null;
timer = null;
ease = null;
completionCallback = null;
progressCallback = null;
}
/**
* Starts shaking behavior.
*/
function start(Object:FlxObject, Duration:Float = 1, Interval:Float = 0.04, StartIntensity:Float = 0, EndIntensity:Float = 0, Ease:EaseFunction,
?CompletionCallback:IntervalShake->Void, ?ProgressCallback:IntervalShake->Void):Void
{
object = Object;
duration = Duration;
interval = Interval;
completionCallback = CompletionCallback;
startIntensity = StartIntensity;
endIntensity = EndIntensity;
initialOffset = new FlxPoint(Object.x, Object.y);
ease = Ease;
axes = FlxAxes.XY;
_secondsSinceStart = 0;
timer = new FlxTimer().start(interval, shakeProgress, Std.int(duration / interval));
}
/**
* Prematurely ends shaking.
*/
public function stop():Void
{
timer.cancel();
// object.visible = true;
object.x = initialOffset.x;
object.y = initialOffset.y;
release();
}
/**
* Unbinds the object from shaking and releases it into pool for reuse.
*/
function release():Void
{
_boundObjects.remove(object);
_pool.put(this);
}
public var _secondsSinceStart(default, null):Float = 0;
public var scale(default, null):Float = 0;
/**
* Just a helper function for shake() to update object's position.
*/
function shakeProgress(timer:FlxTimer):Void
{
_secondsSinceStart += interval;
scale = _secondsSinceStart / duration;
if (ease != null)
{
scale = 1 - ease(scale);
// trace(scale);
}
var curIntensity:Float = 0;
curIntensity = FlxMath.lerp(endIntensity, startIntensity, scale);
if (axes.x) object.x = initialOffset.x + FlxG.random.float((-curIntensity) * object.width, (curIntensity) * object.width);
if (axes.y) object.y = initialOffset.y + FlxG.random.float((-curIntensity) * object.width, (curIntensity) * object.width);
// object.visible = !object.visible;
if (progressCallback != null) progressCallback(this);
if (timer.loops > 0 && timer.loopsLeft == 0)
{
object.x = initialOffset.x;
object.y = initialOffset.y;
if (completionCallback != null)
{
completionCallback(this);
}
if (this.timer == timer) release();
}
}
/**
* Internal constructor. Use static methods.
*/
@:keep
function new() {}
}

View file

@ -11,6 +11,7 @@ import flixel.system.debug.watch.Tracker;
// These are great. // These are great.
using Lambda; using Lambda;
using StringTools; using StringTools;
using thx.Arrays;
using funkin.util.tools.ArraySortTools; using funkin.util.tools.ArraySortTools;
using funkin.util.tools.ArrayTools; using funkin.util.tools.ArrayTools;
using funkin.util.tools.FloatTools; using funkin.util.tools.FloatTools;

View file

@ -715,7 +715,7 @@ class Controls extends FlxActionSet
case Control.VOLUME_UP: return [PLUS, NUMPADPLUS]; case Control.VOLUME_UP: return [PLUS, NUMPADPLUS];
case Control.VOLUME_DOWN: return [MINUS, NUMPADMINUS]; case Control.VOLUME_DOWN: return [MINUS, NUMPADMINUS];
case Control.VOLUME_MUTE: return [ZERO, NUMPADZERO]; case Control.VOLUME_MUTE: return [ZERO, NUMPADZERO];
case Control.FULLSCREEN: return [FlxKey.F]; case Control.FULLSCREEN: return [FlxKey.F11]; // We use F for other things LOL.
} }
case Duo(true): case Duo(true):
@ -997,7 +997,7 @@ class Controls extends FlxActionSet
for (control in Control.createAll()) for (control in Control.createAll())
{ {
var inputs:Array<Int> = Reflect.field(data, control.getName()); var inputs:Array<Int> = Reflect.field(data, control.getName());
inputs = inputs.unique(); inputs = inputs.distinct();
if (inputs != null) if (inputs != null)
{ {
if (inputs.length == 0) { if (inputs.length == 0) {
@ -1050,7 +1050,7 @@ class Controls extends FlxActionSet
if (inputs.length == 0) { if (inputs.length == 0) {
inputs = [FlxKey.NONE]; inputs = [FlxKey.NONE];
} else { } else {
inputs = inputs.unique(); inputs = inputs.distinct();
} }
Reflect.setField(data, control.getName(), inputs); Reflect.setField(data, control.getName(), inputs);

View file

@ -2804,6 +2804,7 @@ class PlayState extends MusicBeatSubState
deathCounter = 0; deathCounter = 0;
var isNewHighscore = false; var isNewHighscore = false;
var prevScoreData:Null<SaveScoreData> = Save.instance.getSongScore(currentSong.id, currentDifficulty);
if (currentSong != null && currentSong.validScore) if (currentSong != null && currentSong.validScore)
{ {
@ -2823,7 +2824,6 @@ class PlayState extends MusicBeatSubState
totalNotesHit: Highscore.tallies.totalNotesHit, totalNotesHit: Highscore.tallies.totalNotesHit,
totalNotes: Highscore.tallies.totalNotes, totalNotes: Highscore.tallies.totalNotes,
}, },
accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes,
}; };
// adds current song data into the tallies for the level (story levels) // adds current song data into the tallies for the level (story levels)
@ -2860,7 +2860,7 @@ class PlayState extends MusicBeatSubState
score: PlayStatePlaylist.campaignScore, score: PlayStatePlaylist.campaignScore,
tallies: tallies:
{ {
// TODO: Sum up the values for the whole level! // TODO: Sum up the values for the whole week!
sick: 0, sick: 0,
good: 0, good: 0,
bad: 0, bad: 0,
@ -2871,7 +2871,6 @@ class PlayState extends MusicBeatSubState
totalNotesHit: 0, totalNotesHit: 0,
totalNotes: 0, totalNotes: 0,
}, },
accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes,
}; };
if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data)) if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data))
@ -2957,11 +2956,11 @@ class PlayState extends MusicBeatSubState
{ {
if (rightGoddamnNow) if (rightGoddamnNow)
{ {
moveToResultsScreen(isNewHighscore); moveToResultsScreen(isNewHighscore, prevScoreData);
} }
else else
{ {
zoomIntoResultsScreen(isNewHighscore); zoomIntoResultsScreen(isNewHighscore, prevScoreData);
} }
} }
} }
@ -3035,7 +3034,7 @@ class PlayState extends MusicBeatSubState
/** /**
* Play the camera zoom animation and then move to the results screen once it's done. * Play the camera zoom animation and then move to the results screen once it's done.
*/ */
function zoomIntoResultsScreen(isNewHighscore:Bool):Void function zoomIntoResultsScreen(isNewHighscore:Bool, ?prevScoreData:SaveScoreData):Void
{ {
trace('WENT TO RESULTS SCREEN!'); trace('WENT TO RESULTS SCREEN!');
@ -3075,7 +3074,7 @@ class PlayState extends MusicBeatSubState
FlxTween.tween(camHUD, {alpha: 0}, 0.6, FlxTween.tween(camHUD, {alpha: 0}, 0.6,
{ {
onComplete: function(_) { onComplete: function(_) {
moveToResultsScreen(isNewHighscore); moveToResultsScreen(isNewHighscore, prevScoreData);
} }
}); });
@ -3108,7 +3107,7 @@ class PlayState extends MusicBeatSubState
/** /**
* Move to the results screen right goddamn now. * Move to the results screen right goddamn now.
*/ */
function moveToResultsScreen(isNewHighscore:Bool):Void function moveToResultsScreen(isNewHighscore:Bool, ?prevScoreData:SaveScoreData):Void
{ {
persistentUpdate = false; persistentUpdate = false;
vocals.stop(); vocals.stop();
@ -3120,6 +3119,8 @@ class PlayState extends MusicBeatSubState
{ {
storyMode: PlayStatePlaylist.isStoryMode, storyMode: PlayStatePlaylist.isStoryMode,
title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'), title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'),
prevScoreData: prevScoreData,
difficultyId: currentDifficulty,
scoreData: scoreData:
{ {
score: PlayStatePlaylist.isStoryMode ? PlayStatePlaylist.campaignScore : songScore, score: PlayStatePlaylist.isStoryMode ? PlayStatePlaylist.campaignScore : songScore,
@ -3135,7 +3136,6 @@ class PlayState extends MusicBeatSubState
totalNotesHit: talliesToUse.totalNotesHit, totalNotesHit: talliesToUse.totalNotesHit,
totalNotes: talliesToUse.totalNotes, totalNotes: talliesToUse.totalNotes,
}, },
accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes,
}, },
isNewHighscore: isNewHighscore isNewHighscore: isNewHighscore
}); });

View file

@ -12,6 +12,8 @@ import funkin.ui.MusicBeatSubState;
import flixel.math.FlxRect; import flixel.math.FlxRect;
import flixel.text.FlxBitmapText; import flixel.text.FlxBitmapText;
import funkin.ui.freeplay.FreeplayScore; import funkin.ui.freeplay.FreeplayScore;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import funkin.ui.freeplay.FreeplayState; import funkin.ui.freeplay.FreeplayState;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
@ -22,153 +24,196 @@ import funkin.save.Save;
import funkin.save.Save.SaveScoreData; import funkin.save.Save.SaveScoreData;
import funkin.graphics.shaders.LeftMaskShader; import funkin.graphics.shaders.LeftMaskShader;
import funkin.play.components.TallyCounter; import funkin.play.components.TallyCounter;
import funkin.play.components.ClearPercentCounter;
/** /**
* The state for the results screen after a song or week is finished. * The state for the results screen after a song or week is finished.
*/ */
@:nullSafety
class ResultState extends MusicBeatSubState class ResultState extends MusicBeatSubState
{ {
final params:ResultsStateParams; final params:ResultsStateParams;
var resultsVariation:ResultVariations; final rank:ResultRank;
var songName:FlxBitmapText; final songName:FlxBitmapText;
var difficulty:FlxSprite; final difficulty:FlxSprite;
final clearPercentSmall:ClearPercentCounter;
var maskShaderSongName:LeftMaskShader = new LeftMaskShader(); final maskShaderSongName:LeftMaskShader = new LeftMaskShader();
var maskShaderDifficulty:LeftMaskShader = new LeftMaskShader(); final maskShaderDifficulty:LeftMaskShader = new LeftMaskShader();
final resultsAnim:FunkinSprite;
final ratingsPopin:FunkinSprite;
final scorePopin:FunkinSprite;
final bgFlash:FlxSprite;
final highscoreNew:FlxSprite;
final score:ResultScore;
var bfPerfect:Null<FlxAtlasSprite> = null;
var bfExcellent:Null<FlxAtlasSprite> = null;
var bfGreat:Null<FlxAtlasSprite> = null;
var bfGood:Null<FlxSprite> = null;
var gfGood:Null<FlxSprite> = null;
var bfShit:Null<FlxAtlasSprite> = null;
public function new(params:ResultsStateParams) public function new(params:ResultsStateParams)
{ {
super(); super();
this.params = params; this.params = params;
}
override function create():Void rank = calculateRank(params);
{ // rank = SHIT;
/*
if (params.scoreData.sick == params.scoreData.totalNotesHit
&& params.scoreData.maxCombo == params.scoreData.totalNotesHit) resultsVariation = PERFECT;
else if (params.scoreData.missed + params.scoreData.bad + params.scoreData.shit >= params.scoreData.totalNotes * 0.50)
resultsVariation = SHIT; // if more than half of your song was missed, bad, or shit notes, you get shit ending!
else
resultsVariation = NORMAL;
*/
resultsVariation = NORMAL;
FunkinSound.playMusic('results$resultsVariation', // We build a lot of this stuff in the constructor, then place it in create().
{ // This prevents having to do `null` checks everywhere.
startingVolume: 1.0,
overrideExisting: true,
restartTrack: true,
loop: resultsVariation != SHIT
});
// Reset the camera zoom on the results screen.
FlxG.camera.zoom = 1.0;
// TEMP-ish, just used to sorta "cache" the 3000x3000 image!
var cacheBullShit:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/soundSystem"));
add(cacheBullShit);
var dumb:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/scorePopin"));
add(dumb);
var bg:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFECC5C, 0xFFFDC05C], 90);
bg.scrollFactor.set();
add(bg);
var bgFlash:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90);
bgFlash.scrollFactor.set();
bgFlash.visible = false;
add(bgFlash);
// var bfGfExcellent:FlxAtlasSprite = new FlxAtlasSprite(380, -170, Paths.animateAtlas("resultScreen/resultsBoyfriendExcellent", "shared"));
// bfGfExcellent.visible = false;
// add(bfGfExcellent);
//
// var bfPerfect:FlxAtlasSprite = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/resultsBoyfriendPerfect", "shared"));
// bfPerfect.visible = false;
// add(bfPerfect);
//
// var bfSHIT:FlxAtlasSprite = new FlxAtlasSprite(0, 20, Paths.animateAtlas("resultScreen/resultsBoyfriendSHIT", "shared"));
// bfSHIT.visible = false;
// add(bfSHIT);
//
// bfGfExcellent.anim.onComplete = () -> {
// bfGfExcellent.anim.curFrame = 28;
// bfGfExcellent.anim.play(); // unpauses this anim, since it's on PlayOnce!
// };
//
// bfPerfect.anim.onComplete = () -> {
// bfPerfect.anim.curFrame = 136;
// bfPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
// };
//
// bfSHIT.anim.onComplete = () -> {
// bfSHIT.anim.curFrame = 150;
// bfSHIT.anim.play(); // unpauses this anim, since it's on PlayOnce!
// };
var gf:FlxSprite = FunkinSprite.createSparrow(625, 325, 'resultScreen/resultGirlfriendGOOD');
gf.animation.addByPrefix("clap", "Girlfriend Good Anim", 24, false);
gf.visible = false;
gf.animation.finishCallback = _ -> {
gf.animation.play('clap', true, false, 9);
};
add(gf);
var boyfriend:FlxSprite = FunkinSprite.createSparrow(640, -200, 'resultScreen/resultBoyfriendGOOD');
boyfriend.animation.addByPrefix("fall", "Boyfriend Good Anim0", 24, false);
boyfriend.visible = false;
boyfriend.animation.finishCallback = function(_) {
boyfriend.animation.play('fall', true, false, 14);
};
add(boyfriend);
var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem');
soundSystem.animation.addByPrefix("idle", "sound system", 24, false);
soundSystem.visible = false;
new FlxTimer().start(0.4, _ -> {
soundSystem.animation.play("idle");
soundSystem.visible = true;
});
add(soundSystem);
difficulty = new FlxSprite(555);
var diffSpr:String = switch (PlayState.instance.currentDifficulty)
{
case 'easy':
'difEasy';
case 'normal':
'difNormal';
case 'hard':
'difHard';
case 'erect':
'difErect';
case 'nightmare':
'difNightmare';
case _:
'difNormal';
}
difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr));
add(difficulty);
var fontLetters:String = "AaBbCcDdEeFfGgHhiIJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:1234567890"; var fontLetters:String = "AaBbCcDdEeFfGgHhiIJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz:1234567890";
songName = new FlxBitmapText(FlxBitmapFont.fromMonospace(Paths.image("resultScreen/tardlingSpritesheet"), fontLetters, FlxPoint.get(49, 62))); songName = new FlxBitmapText(FlxBitmapFont.fromMonospace(Paths.image("resultScreen/tardlingSpritesheet"), fontLetters, FlxPoint.get(49, 62)));
songName.text = params.title; songName.text = params.title;
songName.letterSpacing = -15; songName.letterSpacing = -15;
songName.angle = -4.4; songName.angle = -4.4;
songName.zIndex = 1000;
difficulty = new FlxSprite(555);
difficulty.zIndex = 1000;
clearPercentSmall = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, 100, true);
clearPercentSmall.zIndex = 1000;
clearPercentSmall.visible = false;
bgFlash = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90);
resultsAnim = FunkinSprite.createSparrow(-200, -10, "resultScreen/results");
ratingsPopin = FunkinSprite.createSparrow(-150, 120, "resultScreen/ratingsPopin");
scorePopin = FunkinSprite.createSparrow(-180, 520, "resultScreen/scorePopin");
highscoreNew = new FlxSprite(310, 570);
score = new ResultScore(35, 305, 10, params.scoreData.score);
}
override function create():Void
{
// Reset the camera zoom on the results screen.
FlxG.camera.zoom = 1.0;
var bg:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFECC5C, 0xFFFDC05C], 90);
bg.scrollFactor.set();
bg.zIndex = 10;
add(bg);
bgFlash.scrollFactor.set();
bgFlash.visible = false;
bgFlash.zIndex = 20;
add(bgFlash);
// The sound system which falls into place behind the score text. Plays every time!
var soundSystem:FlxSprite = FunkinSprite.createSparrow(-15, -180, 'resultScreen/soundSystem');
soundSystem.animation.addByPrefix("idle", "sound system", 24, false);
soundSystem.visible = false;
new FlxTimer().start(0.3, _ -> {
soundSystem.animation.play("idle");
soundSystem.visible = true;
});
soundSystem.zIndex = 1100;
add(soundSystem);
switch (rank)
{
case PERFECT | PERFECT_GOLD:
bfPerfect = new FlxAtlasSprite(370, -180, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
bfPerfect.visible = false;
bfPerfect.zIndex = 500;
add(bfPerfect);
bfPerfect.anim.onComplete = () -> {
if (bfPerfect != null)
{
bfPerfect.anim.curFrame = 137;
bfPerfect.anim.play(); // unpauses this anim, since it's on PlayOnce!
}
};
case EXCELLENT:
bfExcellent = new FlxAtlasSprite(380, -170, Paths.animateAtlas("resultScreen/results-bf/resultsEXCELLENT", "shared"));
bfExcellent.visible = false;
bfExcellent.zIndex = 500;
add(bfExcellent);
bfExcellent.onAnimationFinish.add((animName) -> {
if (bfExcellent != null)
{
bfExcellent.playAnimation('Loop Start');
}
});
case GREAT:
bfGreat = new FlxAtlasSprite(640, 200, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT", "shared"));
bfGreat.visible = false;
bfGreat.zIndex = 500;
add(bfGreat);
bfGreat.onAnimationFinish.add((animName) -> {
if (bfGreat != null)
{
bfGreat.playAnimation('Loop Start');
}
});
case GOOD:
gfGood = FunkinSprite.createSparrow(625, 325, 'resultScreen/results-bf/resultsGOOD/resultGirlfriendGOOD');
gfGood.animation.addByPrefix("clap", "Girlfriend Good Anim", 24, false);
gfGood.visible = false;
gfGood.zIndex = 500;
gfGood.animation.finishCallback = _ -> {
if (gfGood != null)
{
gfGood.animation.play('clap', true, false, 9);
}
};
add(gfGood);
bfGood = FunkinSprite.createSparrow(640, -200, 'resultScreen/results-bf/resultsGOOD/resultBoyfriendGOOD');
bfGood.animation.addByPrefix("fall", "Boyfriend Good Anim0", 24, false);
bfGood.visible = false;
bfGood.zIndex = 501;
bfGood.animation.finishCallback = function(_) {
if (bfGood != null)
{
bfGood.animation.play('fall', true, false, 14);
}
};
add(bfGood);
case SHIT:
bfShit = new FlxAtlasSprite(0, 20, Paths.animateAtlas("resultScreen/results-bf/resultsSHIT", "shared"));
bfShit.visible = false;
bfShit.zIndex = 500;
add(bfShit);
bfShit.onAnimationFinish.add((animName) -> {
if (bfShit != null)
{
bfShit.playAnimation('Loop Start');
}
});
}
var diffSpr:String = 'dif${params?.difficultyId ?? 'Normal'}';
difficulty.loadGraphic(Paths.image("resultScreen/" + diffSpr));
add(difficulty);
add(songName); add(songName);
var angleRad = songName.angle * Math.PI / 180; var angleRad = songName.angle * Math.PI / 180;
speedOfTween.x = -1.0 * Math.cos(angleRad); speedOfTween.x = -1.0 * Math.cos(angleRad);
speedOfTween.y = -1.0 * Math.sin(angleRad); speedOfTween.y = -1.0 * Math.sin(angleRad);
timerThenSongName(); timerThenSongName(1.0, false);
songName.shader = maskShaderSongName; songName.shader = maskShaderSongName;
difficulty.shader = maskShaderDifficulty; difficulty.shader = maskShaderDifficulty;
@ -178,35 +223,53 @@ class ResultState extends MusicBeatSubState
var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack")); var blackTopBar:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/topBarBlack"));
blackTopBar.y = -blackTopBar.height; blackTopBar.y = -blackTopBar.height;
FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut, startDelay: 0.5}); FlxTween.tween(blackTopBar, {y: 0}, 0.4, {ease: FlxEase.quartOut});
blackTopBar.zIndex = 1010;
add(blackTopBar); add(blackTopBar);
var resultsAnim:FunkinSprite = FunkinSprite.createSparrow(-200, -10, "resultScreen/results");
resultsAnim.animation.addByPrefix("result", "results instance 1", 24, false); resultsAnim.animation.addByPrefix("result", "results instance 1", 24, false);
resultsAnim.animation.play("result"); resultsAnim.visible = false;
resultsAnim.zIndex = 1200;
add(resultsAnim); add(resultsAnim);
new FlxTimer().start(0.3, _ -> {
resultsAnim.visible = true;
resultsAnim.animation.play("result");
});
var ratingsPopin:FunkinSprite = FunkinSprite.createSparrow(-150, 120, "resultScreen/ratingsPopin");
ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false); ratingsPopin.animation.addByPrefix("idle", "Categories", 24, false);
ratingsPopin.visible = false; ratingsPopin.visible = false;
ratingsPopin.zIndex = 1200;
add(ratingsPopin); add(ratingsPopin);
new FlxTimer().start(1.0, _ -> {
ratingsPopin.visible = true;
ratingsPopin.animation.play("idle");
});
var scorePopin:FunkinSprite = FunkinSprite.createSparrow(-180, 520, "resultScreen/scorePopin");
scorePopin.animation.addByPrefix("score", "tally score", 24, false); scorePopin.animation.addByPrefix("score", "tally score", 24, false);
scorePopin.visible = false; scorePopin.visible = false;
scorePopin.zIndex = 1200;
add(scorePopin); add(scorePopin);
new FlxTimer().start(1.0, _ -> {
scorePopin.visible = true;
scorePopin.animation.play("score");
scorePopin.animation.finishCallback = anim -> {
score.visible = true;
score.animateNumbers();
};
});
var highscoreNew:FlxSprite = new FlxSprite(310, 570);
highscoreNew.frames = Paths.getSparrowAtlas("resultScreen/highscoreNew"); highscoreNew.frames = Paths.getSparrowAtlas("resultScreen/highscoreNew");
highscoreNew.animation.addByPrefix("new", "NEW HIGHSCORE", 24); highscoreNew.animation.addByPrefix("new", "NEW HIGHSCORE", 24);
highscoreNew.visible = false; highscoreNew.visible = false;
highscoreNew.setGraphicSize(Std.int(highscoreNew.width * 0.8)); highscoreNew.setGraphicSize(Std.int(highscoreNew.width * 0.8));
highscoreNew.updateHitbox(); highscoreNew.updateHitbox();
highscoreNew.zIndex = 1200;
add(highscoreNew); add(highscoreNew);
var hStuf:Int = 50; var hStuf:Int = 50;
var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>(); var ratingGrp:FlxTypedGroup<TallyCounter> = new FlxTypedGroup<TallyCounter>();
ratingGrp.zIndex = 1200;
add(ratingGrp); add(ratingGrp);
/** /**
@ -236,32 +299,23 @@ class ResultState extends MusicBeatSubState
var tallyMissed:TallyCounter = new TallyCounter(260, (hStuf * 9) + extraYOffset, params.scoreData.tallies.missed, 0xFFC68AE6); var tallyMissed:TallyCounter = new TallyCounter(260, (hStuf * 9) + extraYOffset, params.scoreData.tallies.missed, 0xFFC68AE6);
ratingGrp.add(tallyMissed); ratingGrp.add(tallyMissed);
var score:ResultScore = new ResultScore(35, 305, 10, params.scoreData.score);
score.visible = false; score.visible = false;
score.zIndex = 1200;
add(score); add(score);
for (ind => rating in ratingGrp.members) for (ind => rating in ratingGrp.members)
{ {
rating.visible = false; rating.visible = false;
new FlxTimer().start((0.3 * ind) + 0.55, _ -> { new FlxTimer().start((0.3 * ind) + 1.20, _ -> {
rating.visible = true; rating.visible = true;
FlxTween.tween(rating, {curNumber: rating.neededNumber}, 0.5, {ease: FlxEase.quartOut}); FlxTween.tween(rating, {curNumber: rating.neededNumber}, 0.5, {ease: FlxEase.quartOut});
}); });
} }
new FlxTimer().start(0.5, _ -> {
ratingsPopin.animation.play("idle");
ratingsPopin.visible = true;
ratingsPopin.animation.finishCallback = anim -> { ratingsPopin.animation.finishCallback = anim -> {
scorePopin.animation.play("score"); startRankTallySequence();
scorePopin.animation.finishCallback = anim -> {
score.visible = true;
score.animateNumbers();
};
scorePopin.visible = true;
if (params.isNewHighscore) if (params.isNewHighscore ?? false)
{ {
highscoreNew.visible = true; highscoreNew.visible = true;
highscoreNew.animation.play("new"); highscoreNew.animation.play("new");
@ -273,46 +327,219 @@ class ResultState extends MusicBeatSubState
} }
}; };
switch (resultsVariation) refresh();
{
// case SHIT:
// bfSHIT.visible = true;
// bfSHIT.playAnimation("");
case NORMAL:
boyfriend.animation.play('fall');
boyfriend.visible = true;
new FlxTimer().start((1 / 24) * 12, _ -> {
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
new FlxTimer().start((1 / 24) * 2, _ ->
{
// bgFlash.alpha = 0.5;
// bgFlash.visible = false;
});
});
new FlxTimer().start((1 / 24) * 22, _ -> {
// plays about 22 frames (at 24fps timing) after bf spawns in
gf.animation.play('clap', true);
gf.visible = true;
});
// case PERFECT:
// bfPerfect.visible = true;
// bfPerfect.playAnimation("");
// bfGfExcellent.visible = true;
// bfGfExcellent.playAnimation("");
default:
}
});
super.create(); super.create();
} }
function timerThenSongName():Void var rankTallyTimer:Null<FlxTimer> = null;
var clearPercentTarget:Int = 100;
var clearPercentLerp:Int = 0;
function startRankTallySequence():Void
{
var clearPercentFloat = (params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes * 100;
clearPercentTarget = Math.floor(clearPercentFloat);
// Prevent off-by-one errors.
clearPercentLerp = Std.int(Math.max(0, clearPercentTarget - 36));
trace('Clear percent target: ' + clearPercentFloat + ', round: ' + clearPercentTarget);
var clearPercentCounter:ClearPercentCounter = new ClearPercentCounter(FlxG.width / 2 + 300, FlxG.height / 2 - 100, clearPercentLerp);
FlxTween.tween(clearPercentCounter, {curNumber: clearPercentTarget}, 1.5,
{
ease: FlxEase.quartOut,
onUpdate: _ -> {
// Only play the tick sound if the number increased.
if (clearPercentLerp != clearPercentCounter.curNumber)
{
clearPercentLerp = clearPercentCounter.curNumber;
FunkinSound.playOnce(Paths.sound('scrollMenu'));
}
},
onComplete: _ -> {
// Play confirm sound.
FunkinSound.playOnce(Paths.sound('confirmMenu'));
// Flash background.
bgFlash.visible = true;
FlxTween.tween(bgFlash, {alpha: 0}, 0.4);
// Just to be sure that the lerp didn't mess things up.
clearPercentCounter.curNumber = clearPercentTarget;
clearPercentCounter.flash(true);
new FlxTimer().start(0.4, _ -> {
clearPercentCounter.flash(false);
});
displayRankText();
new FlxTimer().start(2.0, _ -> {
FlxTween.tween(clearPercentCounter, {alpha: 0}, 0.5,
{
startDelay: 0.5,
ease: FlxEase.quartOut,
onComplete: _ -> {
remove(clearPercentCounter);
}
});
afterRankTallySequence();
});
}
});
clearPercentCounter.zIndex = 450;
add(clearPercentCounter);
if (ratingsPopin == null)
{
trace("Could not build ratingsPopin!");
}
else
{
// ratingsPopin.animation.play("idle");
// ratingsPopin.visible = true;
ratingsPopin.animation.finishCallback = anim -> {
// scorePopin.animation.play("score");
// scorePopin.visible = true;
if (params.isNewHighscore ?? false)
{
highscoreNew.visible = true;
highscoreNew.animation.play("new");
FlxTween.tween(highscoreNew, {y: highscoreNew.y + 10}, 0.8, {ease: FlxEase.quartOut});
}
else
{
highscoreNew.visible = false;
}
};
}
refresh();
}
function displayRankText():Void
{
var rankTextVert:FunkinSprite = FunkinSprite.create(FlxG.width - 64, 100, rank.getVerTextAsset());
rankTextVert.zIndex = 2000;
add(rankTextVert);
for (i in 0...10)
{
var rankTextBack:FunkinSprite = FunkinSprite.create(FlxG.width / 2 - 80, 50, rank.getHorTextAsset());
rankTextBack.y += (rankTextBack.height * i / 2) + 10;
rankTextBack.zIndex = 100;
add(rankTextBack);
}
refresh();
}
function afterRankTallySequence():Void
{
showSmallClearPercent();
FunkinSound.playMusic(rank.getMusicPath(),
{
startingVolume: 1.0,
overrideExisting: true,
restartTrack: true,
loop: rank.shouldMusicLoop()
});
FlxG.sound.music.onComplete = () -> {
if (rank == SHIT)
{
FunkinSound.playMusic('bluu',
{
startingVolume: 0.0,
overrideExisting: true,
restartTrack: true,
loop: true
});
FlxG.sound.music.fadeIn(10.0, 0.0, 1.0);
}
}
switch (rank)
{
case PERFECT | PERFECT_GOLD:
if (bfPerfect == null)
{
trace("Could not build PERFECT animation!");
}
else
{
bfPerfect.visible = true;
bfPerfect.playAnimation('');
}
case EXCELLENT:
if (bfExcellent == null)
{
trace("Could not build EXCELLENT animation!");
}
else
{
bfExcellent.visible = true;
bfExcellent.playAnimation('Intro');
}
case GREAT:
if (bfGreat == null)
{
trace("Could not build GREAT animation!");
}
else
{
bfGreat.visible = true;
bfGreat.playAnimation('Intro');
}
case SHIT:
if (bfShit == null)
{
trace("Could not build SHIT animation!");
}
else
{
bfShit.visible = true;
bfShit.playAnimation('Intro');
}
case GOOD:
if (bfGood == null)
{
trace("Could not build GOOD animation!");
}
else
{
bfGood.animation.play('fall');
bfGood.visible = true;
new FlxTimer().start((1 / 24) * 22, _ -> {
// plays about 22 frames (at 24fps timing) after bf spawns in
if (gfGood != null)
{
gfGood.animation.play('clap', true);
gfGood.visible = true;
}
else
{
trace("Could not build GOOD animation!");
}
});
}
default:
}
}
function timerThenSongName(timerLength:Float = 3.0, autoScroll:Bool = true):Void
{ {
movingSongStuff = false; movingSongStuff = false;
@ -323,21 +550,47 @@ class ResultState extends MusicBeatSubState
difficulty.y = -difficulty.height; difficulty.y = -difficulty.height;
FlxTween.tween(difficulty, {y: diffYTween}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.8}); FlxTween.tween(difficulty, {y: diffYTween}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.8});
if (clearPercentSmall != null)
{
clearPercentSmall.x = (difficulty.x + difficulty.width) + 60;
clearPercentSmall.y = -clearPercentSmall.height;
FlxTween.tween(clearPercentSmall, {y: 122 - 5}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.8});
}
songName.y = -songName.height; songName.y = -songName.height;
var fuckedupnumber = (10) * (songName.text.length / 15); var fuckedupnumber = (10) * (songName.text.length / 15);
FlxTween.tween(songName, {y: diffYTween - 35 - fuckedupnumber}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.9}); FlxTween.tween(songName, {y: diffYTween - 25 - fuckedupnumber}, 0.5, {ease: FlxEase.expoOut, startDelay: 0.9});
songName.x = (difficulty.x + difficulty.width) + 20; songName.x = clearPercentSmall.x + clearPercentSmall.width - 30;
new FlxTimer().start(3, _ -> { new FlxTimer().start(timerLength, _ -> {
var tempSpeed = FlxPoint.get(speedOfTween.x, speedOfTween.y); var tempSpeed = FlxPoint.get(speedOfTween.x, speedOfTween.y);
speedOfTween.set(0, 0); speedOfTween.set(0, 0);
FlxTween.tween(speedOfTween, {x: tempSpeed.x, y: tempSpeed.y}, 0.7, {ease: FlxEase.quadIn}); FlxTween.tween(speedOfTween, {x: tempSpeed.x, y: tempSpeed.y}, 0.7, {ease: FlxEase.quadIn});
movingSongStuff = true; movingSongStuff = (autoScroll);
}); });
} }
function showSmallClearPercent():Void
{
if (clearPercentSmall != null)
{
add(clearPercentSmall);
clearPercentSmall.visible = true;
clearPercentSmall.flash(true);
new FlxTimer().start(0.4, _ -> {
clearPercentSmall.flash(false);
});
clearPercentSmall.curNumber = clearPercentTarget;
clearPercentSmall.zIndex = 1000;
refresh();
}
movingSongStuff = true;
}
var movingSongStuff:Bool = false; var movingSongStuff:Bool = false;
var speedOfTween:FlxPoint = FlxPoint.get(-1, 1); var speedOfTween:FlxPoint = FlxPoint.get(-1, 1);
@ -345,11 +598,9 @@ class ResultState extends MusicBeatSubState
{ {
super.draw(); super.draw();
if (songName != null) songName.clipRect = FlxRect.get(Math.max(0, 520 - songName.x), 0, FlxG.width, songName.height);
{
songName.clipRect = FlxRect.get(Math.max(0, 540 - songName.x), 0, FlxG.width, songName.height);
// PROBABLY SHOULD FIX MEMORY FREE OR WHATEVER THE PUT() FUNCTION DOES !!!! FEELS LIKE IT STUTTERS!!! // PROBABLY SHOULD FIX MEMORY FREE OR WHATEVER THE PUT() FUNCTION DOES !!!! FEELS LIKE IT STUTTERS!!!
}
// if (songName != null && songName.frame != null) // if (songName != null && songName.frame != null)
// maskShaderSongName.frameUV = songName.frame.uv; // maskShaderSongName.frameUV = songName.frame.uv;
@ -364,8 +615,10 @@ class ResultState extends MusicBeatSubState
{ {
songName.x += speedOfTween.x; songName.x += speedOfTween.x;
difficulty.x += speedOfTween.x; difficulty.x += speedOfTween.x;
clearPercentSmall.x += speedOfTween.x;
songName.y += speedOfTween.y; songName.y += speedOfTween.y;
difficulty.y += speedOfTween.y; difficulty.y += speedOfTween.y;
clearPercentSmall.y += speedOfTween.y;
if (songName.x + songName.width < 100) if (songName.x + songName.width < 100)
{ {
@ -401,14 +654,135 @@ class ResultState extends MusicBeatSubState
super.update(elapsed); super.update(elapsed);
} }
public static function calculateRank(params:ResultsStateParams):ResultRank
{
// Perfect (Platinum) is a Sick Full Clear
var isPerfectGold = params.scoreData.tallies.sick == params.scoreData.tallies.totalNotes;
if (isPerfectGold) return ResultRank.PERFECT_GOLD;
// Else, use the standard grades
// Grade % (only good and sick), 1.00 is a full combo
var grade = (params.scoreData.tallies.sick + params.scoreData.tallies.good) / params.scoreData.tallies.totalNotes;
// Clear % (including bad and shit). 1.00 is a full clear but not a full combo
var clear = (params.scoreData.tallies.totalNotesHit) / params.scoreData.tallies.totalNotes;
if (grade == Constants.RANK_PERFECT_THRESHOLD)
{
return ResultRank.PERFECT;
}
else if (grade >= Constants.RANK_EXCELLENT_THRESHOLD)
{
return ResultRank.EXCELLENT;
}
else if (grade >= Constants.RANK_GREAT_THRESHOLD)
{
return ResultRank.GREAT;
}
else if (grade >= Constants.RANK_GOOD_THRESHOLD)
{
return ResultRank.GOOD;
}
else
{
return ResultRank.SHIT;
}
}
} }
enum abstract ResultVariations(String) enum abstract ResultRank(String)
{ {
var PERFECT_GOLD;
var PERFECT; var PERFECT;
var EXCELLENT; var EXCELLENT;
var NORMAL; var GREAT;
var GOOD;
var SHIT; var SHIT;
public function getMusicPath():String
{
switch (abstract)
{
case PERFECT_GOLD:
return 'resultsPERFECT';
case PERFECT:
return 'resultsPERFECT';
case EXCELLENT:
return 'resultsNORMAL';
case GREAT:
return 'resultsNORMAL';
case GOOD:
return 'resultsNORMAL';
case SHIT:
return 'resultsSHIT';
default:
return 'resultsNORMAL';
}
}
public function shouldMusicLoop():Bool
{
switch (abstract)
{
case PERFECT_GOLD:
return true;
case PERFECT:
return true;
case EXCELLENT:
return true;
case GREAT:
return true;
case GOOD:
return true;
case SHIT:
return false;
default:
return false;
}
}
public function getHorTextAsset()
{
switch (abstract)
{
case PERFECT_GOLD:
return 'resultScreen/rankText/rankScrollPERFECT';
case PERFECT:
return 'resultScreen/rankText/rankScrollPERFECT';
case EXCELLENT:
return 'resultScreen/rankText/rankScrollEXCELLENT';
case GREAT:
return 'resultScreen/rankText/rankScrollGREAT';
case GOOD:
return 'resultScreen/rankText/rankScrollGOOD';
case SHIT:
return 'resultScreen/rankText/rankScrollLOSS';
default:
return 'resultScreen/rankText/rankScrollGOOD';
}
}
public function getVerTextAsset()
{
switch (abstract)
{
case PERFECT_GOLD:
return 'resultScreen/rankText/rankTextPERFECT';
case PERFECT:
return 'resultScreen/rankText/rankTextPERFECT';
case EXCELLENT:
return 'resultScreen/rankText/rankTextEXCELLENT';
case GREAT:
return 'resultScreen/rankText/rankTextGREAT';
case GOOD:
return 'resultScreen/rankText/rankTextGOOD';
case SHIT:
return 'resultScreen/rankText/rankTextLOSS';
default:
return 'resultScreen/rankText/rankTextGOOD';
}
}
} }
typedef ResultsStateParams = typedef ResultsStateParams =
@ -426,10 +800,21 @@ typedef ResultsStateParams =
/** /**
* Whether the displayed score is a new highscore * Whether the displayed score is a new highscore
*/ */
var isNewHighscore:Bool; var ?isNewHighscore:Bool;
/**
* The difficulty ID of the song/week we just played.
* @default Normal
*/
var ?difficultyId:String;
/** /**
* The score, accuracy, and judgements. * The score, accuracy, and judgements.
*/ */
var scoreData:SaveScoreData; var scoreData:SaveScoreData;
/**
* The previous score data, used for rank comparision.
*/
var ?prevScoreData:SaveScoreData;
}; };

View file

@ -0,0 +1,137 @@
package funkin.play.components;
import funkin.graphics.FunkinSprite;
import funkin.graphics.shaders.PureColor;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.math.FlxMath;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.text.FlxText.FlxTextAlign;
import funkin.util.MathUtil;
import flixel.util.FlxColor;
/**
* Numerical counters used to display the clear percent.
*/
class ClearPercentCounter extends FlxTypedSpriteGroup<FlxSprite>
{
public var curNumber(default, set):Int = 0;
var numberChanged:Bool = false;
function set_curNumber(val:Int):Int
{
numberChanged = true;
return curNumber = val;
}
var small:Bool = false;
var flashShader:PureColor;
public function new(x:Float, y:Float, startingNumber:Int = 0, small:Bool = false)
{
super(x, y);
flashShader = new PureColor(FlxColor.WHITE);
flashShader.colorSet = true;
curNumber = startingNumber;
this.small = small;
var clearPercentText:FunkinSprite = FunkinSprite.create(0, 0, 'resultScreen/clearPercent/clearPercentText${small ? 'Small' : ''}');
clearPercentText.x = small ? 40 : 0;
add(clearPercentText);
drawNumbers();
}
/**
* Make the counter flash turn white or stop being all white.
* @param enabled Whether the counter should be white.
*/
public function flash(enabled:Bool):Void
{
for (member in members)
{
member.shader = enabled ? flashShader : null;
}
}
var tmr:Float = 0;
override function update(elapsed:Float)
{
super.update(elapsed);
if (numberChanged) drawNumbers();
}
function drawNumbers()
{
var seperatedScore:Array<Int> = [];
var tempCombo:Int = Math.round(curNumber);
while (tempCombo != 0)
{
seperatedScore.push(tempCombo % 10);
tempCombo = Math.floor(tempCombo / 10);
}
if (seperatedScore.length == 0) seperatedScore.push(0);
seperatedScore.reverse();
for (ind => num in seperatedScore)
{
var digitIndex = ind + 1;
// If there's only one digit, move it to the right
// If there's three digits, move them all to the left
var digitOffset = (seperatedScore.length == 1) ? 1 : (seperatedScore.length == 3) ? -1 : 0;
var digitSize = small ? 32 : 72;
var digitHeightOffset = small ? -4 : 0;
var xPos = (digitIndex - 1 + digitOffset) * (digitSize * this.scale.x);
xPos += small ? -24 : 0;
var yPos = (digitIndex - 1 + digitOffset) * (digitHeightOffset * this.scale.y);
yPos += small ? 0 : 72;
if (digitIndex >= members.length)
{
// Three digits = LLR because the 1 and 0 won't be the same anyway.
var variant:Bool = (seperatedScore.length == 3) ? (digitIndex >= 2) : (digitIndex >= 1);
// var variant:Bool = (seperatedScore.length % 2 != 0) ? (digitIndex % 2 == 0) : (digitIndex % 2 == 1);
var numb:ClearPercentNumber = new ClearPercentNumber(xPos, yPos, num, variant, this.small);
numb.scale.set(this.scale.x, this.scale.y);
add(numb);
}
else
{
members[digitIndex].animation.play(Std.string(num));
// Reset the position of the number
members[digitIndex].x = xPos + this.x;
members[digitIndex].y = yPos + this.y;
}
}
}
}
class ClearPercentNumber extends FlxSprite
{
public function new(x:Float, y:Float, digit:Int, variant:Bool, small:Bool)
{
super(x, y);
frames = Paths.getSparrowAtlas('resultScreen/clearPercent/clearPercentNumber${small ? 'Small' : variant ? 'Right' : 'Left'}');
for (i in 0...10)
{
animation.addByPrefix('$i', 'number $i 0', 24, false);
}
animation.play('$digit');
updateHitbox();
}
}

View file

@ -24,7 +24,7 @@ import funkin.util.MathUtil;
* - i.e. `PlayState.instance.iconP1.playAnimation("losing")` * - i.e. `PlayState.instance.iconP1.playAnimation("losing")`
* - Scripts can also utilize all functionality that a normal FlxSprite would have access to, such as adding supplimental animations. * - Scripts can also utilize all functionality that a normal FlxSprite would have access to, such as adding supplimental animations.
* - i.e. `PlayState.instance.iconP1.animation.addByPrefix("jumpscare", "jumpscare", 24, false);` * - i.e. `PlayState.instance.iconP1.animation.addByPrefix("jumpscare", "jumpscare", 24, false);`
* @author MasterEric * @author EliteMasterEric
*/ */
@:nullSafety @:nullSafety
class HealthIcon extends FunkinSprite class HealthIcon extends FunkinSprite

View file

@ -406,7 +406,7 @@ class Strumline extends FlxSpriteGroup
if (Preferences.downscroll) if (Preferences.downscroll)
{ {
holdNote.y = this.y + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2; holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2;
} }
else else
{ {
@ -435,7 +435,7 @@ class Strumline extends FlxSpriteGroup
if (Preferences.downscroll) if (Preferences.downscroll)
{ {
holdNote.y = this.y - holdNote.height + STRUMLINE_SIZE / 2; holdNote.y = this.y - INITIAL_OFFSET - holdNote.height + STRUMLINE_SIZE / 2;
} }
else else
{ {
@ -450,7 +450,7 @@ class Strumline extends FlxSpriteGroup
if (Preferences.downscroll) if (Preferences.downscroll)
{ {
holdNote.y = this.y + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2; holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime, vwoosh) - holdNote.height + STRUMLINE_SIZE / 2;
} }
else else
{ {

View file

@ -399,6 +399,27 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
return null; return null;
} }
/**
* Given that this character is selected in the Freeplay menu,
* which variations should be available?
* @param charId The character ID to query.
* @return An array of available variations.
*/
public function getVariationsByCharId(?charId:String):Array<String>
{
if (charId == null) charId = Constants.DEFAULT_CHARACTER;
if (variations.contains(charId))
{
return [charId];
}
else
{
// TODO: How to exclude character variations while keeping other custom variations?
return variations;
}
}
/** /**
* List all the difficulties in this song. * List all the difficulties in this song.
* *
@ -418,12 +439,16 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
// so we have to map it to the actual difficulty names. // 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. // 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 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 (variationIds.length > 0 && !variationIds.contains(difficulty.variation)) return null; if (variationIds.length > 0 && !variationIds.contains(difficulty.variation)) return null;
return difficulty.difficulty; return difficulty.difficulty;
}).nonNull().unique(); })
.filterNull()
.distinct();
diffFiltered = diffFiltered.filter(function(diffId:String):Bool { diffFiltered = diffFiltered.filter(function(diffId:String):Bool {
if (showHidden) return true; if (showHidden) return true;

View file

@ -14,8 +14,7 @@ import funkin.util.SerializerUtil;
@:nullSafety @:nullSafety
class Save class Save
{ {
// Version 2.0.2 adds attributes to `optionsChartEditor`, that should return default values if they are null. public static final SAVE_DATA_VERSION:thx.semver.Version = "2.0.4";
public static final SAVE_DATA_VERSION:thx.semver.Version = "2.0.3";
public static final SAVE_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x"; public static final SAVE_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x";
// We load this version's saves from a new save path, to maintain SOME level of backwards compatibility. // We load this version's saves from a new save path, to maintain SOME level of backwards compatibility.
@ -53,7 +52,8 @@ class Save
public function new(?data:RawSaveData) public function new(?data:RawSaveData)
{ {
if (data == null) this.data = Save.getDefault(); if (data == null) this.data = Save.getDefault();
else this.data = data; else
this.data = data;
} }
public static function getDefault():RawSaveData public static function getDefault():RawSaveData
@ -77,6 +77,9 @@ class Save
levels: [], levels: [],
songs: [], songs: [],
}, },
favoriteSongs: [],
options: options:
{ {
// Reasonable defaults. // Reasonable defaults.
@ -554,6 +557,35 @@ class Save
return false; return false;
} }
public function isSongFavorited(id:String):Bool
{
if (data.favoriteSongs == null)
{
data.favoriteSongs = [];
flush();
};
return data.favoriteSongs.contains(id);
}
public function favoriteSong(id:String):Void
{
if (!isSongFavorited(id))
{
data.favoriteSongs.push(id);
flush();
}
}
public function unfavoriteSong(id:String):Void
{
if (isSongFavorited(id))
{
data.favoriteSongs.remove(id);
flush();
}
}
public function getControls(playerId:Int, inputType:Device):Null<SaveControlsData> public function getControls(playerId:Int, inputType:Device):Null<SaveControlsData>
{ {
switch (inputType) switch (inputType)
@ -714,6 +746,7 @@ class Save
/** /**
* An anonymous structure containingg all the user's save data. * An anonymous structure containingg all the user's save data.
* Isn't stored with JSON, stored with some sort of Haxe built-in serialization?
*/ */
typedef RawSaveData = typedef RawSaveData =
{ {
@ -724,8 +757,6 @@ typedef RawSaveData =
/** /**
* A semantic versioning string for the save data format. * A semantic versioning string for the save data format.
*/ */
@:jcustomparse(funkin.data.DataParse.semverVersion)
@:jcustomwrite(funkin.data.DataWrite.semverVersion)
var version:Version; var version:Version;
var api:SaveApiData; var api:SaveApiData;
@ -740,6 +771,12 @@ typedef RawSaveData =
*/ */
var options:SaveDataOptions; var options:SaveDataOptions;
/**
* The user's favorited songs in the Freeplay menu,
* as a list of song IDs.
*/
var favoriteSongs:Array<String>;
var mods:SaveDataMods; var mods:SaveDataMods;
/** /**
@ -809,11 +846,6 @@ typedef SaveScoreData =
* The count of each judgement hit. * The count of each judgement hit.
*/ */
var tallies:SaveScoreTallyData; var tallies:SaveScoreTallyData;
/**
* The accuracy percentage.
*/
var accuracy:Float;
} }
typedef SaveScoreTallyData = typedef SaveScoreTallyData =

View file

@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.0.4] - 2024-05-21
### Added
- `favoriteSongs:Array<String>` to `Save`
## [2.0.3] - 2024-01-09 ## [2.0.3] - 2024-01-09
### Added ### Added

View file

@ -3,7 +3,6 @@ package funkin.save.migrator;
import funkin.save.Save; import funkin.save.Save;
import funkin.save.migrator.RawSaveData_v1_0_0; import funkin.save.migrator.RawSaveData_v1_0_0;
import thx.semver.Version; import thx.semver.Version;
import funkin.util.StructureUtil;
import funkin.util.VersionUtil; import funkin.util.VersionUtil;
@:nullSafety @:nullSafety
@ -24,16 +23,20 @@ class SaveDataMigrator
} }
else else
{ {
// Sometimes the Haxe serializer has issues with the version so we fix it here.
version = VersionUtil.repairVersion(version);
if (VersionUtil.validateVersion(version, Save.SAVE_DATA_VERSION_RULE)) if (VersionUtil.validateVersion(version, Save.SAVE_DATA_VERSION_RULE))
{ {
// Simply import the structured data. // Import the structured data.
var save:Save = new Save(StructureUtil.deepMerge(Save.getDefault(), inputData)); var saveDataWithDefaults:RawSaveData = cast thx.Objects.deepCombine(Save.getDefault(), inputData);
var save:Save = new Save(saveDataWithDefaults);
return save; return save;
} }
else else
{ {
trace('[SAVE] Invalid save data version! Returning blank data.'); var message:String = 'Error migrating save data, expected ${Save.SAVE_DATA_VERSION}.';
trace(inputData); lime.app.Application.current.window.alert(message, "Save Data Failure");
trace('[SAVE] ' + message);
return new Save(Save.getDefault()); return new Save(Save.getDefault());
} }
} }
@ -118,7 +121,7 @@ class SaveDataMigrator
var scoreDataEasy:SaveScoreData = var scoreDataEasy:SaveScoreData =
{ {
score: inputSaveData.songScores.get('${levelId}-easy') ?? 0, score: inputSaveData.songScores.get('${levelId}-easy') ?? 0,
accuracy: inputSaveData.songCompletion.get('${levelId}-easy') ?? 0.0, // accuracy: inputSaveData.songCompletion.get('${levelId}-easy') ?? 0.0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -137,7 +140,7 @@ class SaveDataMigrator
var scoreDataNormal:SaveScoreData = var scoreDataNormal:SaveScoreData =
{ {
score: inputSaveData.songScores.get('${levelId}') ?? 0, score: inputSaveData.songScores.get('${levelId}') ?? 0,
accuracy: inputSaveData.songCompletion.get('${levelId}') ?? 0.0, // accuracy: inputSaveData.songCompletion.get('${levelId}') ?? 0.0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -156,7 +159,7 @@ class SaveDataMigrator
var scoreDataHard:SaveScoreData = var scoreDataHard:SaveScoreData =
{ {
score: inputSaveData.songScores.get('${levelId}-hard') ?? 0, score: inputSaveData.songScores.get('${levelId}-hard') ?? 0,
accuracy: inputSaveData.songCompletion.get('${levelId}-hard') ?? 0.0, // accuracy: inputSaveData.songCompletion.get('${levelId}-hard') ?? 0.0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -178,7 +181,6 @@ class SaveDataMigrator
var scoreDataEasy:SaveScoreData = var scoreDataEasy:SaveScoreData =
{ {
score: 0, score: 0,
accuracy: 0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -196,14 +198,13 @@ class SaveDataMigrator
for (songId in songIds) for (songId in songIds)
{ {
scoreDataEasy.score = Std.int(Math.max(scoreDataEasy.score, inputSaveData.songScores.get('${songId}-easy') ?? 0)); scoreDataEasy.score = Std.int(Math.max(scoreDataEasy.score, inputSaveData.songScores.get('${songId}-easy') ?? 0));
scoreDataEasy.accuracy = Math.max(scoreDataEasy.accuracy, inputSaveData.songCompletion.get('${songId}-easy') ?? 0.0); // scoreDataEasy.accuracy = Math.max(scoreDataEasy.accuracy, inputSaveData.songCompletion.get('${songId}-easy') ?? 0.0);
} }
result.setSongScore(songIds[0], 'easy', scoreDataEasy); result.setSongScore(songIds[0], 'easy', scoreDataEasy);
var scoreDataNormal:SaveScoreData = var scoreDataNormal:SaveScoreData =
{ {
score: 0, score: 0,
accuracy: 0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -221,14 +222,13 @@ class SaveDataMigrator
for (songId in songIds) for (songId in songIds)
{ {
scoreDataNormal.score = Std.int(Math.max(scoreDataNormal.score, inputSaveData.songScores.get('${songId}') ?? 0)); scoreDataNormal.score = Std.int(Math.max(scoreDataNormal.score, inputSaveData.songScores.get('${songId}') ?? 0));
scoreDataNormal.accuracy = Math.max(scoreDataNormal.accuracy, inputSaveData.songCompletion.get('${songId}') ?? 0.0); // scoreDataNormal.accuracy = Math.max(scoreDataNormal.accuracy, inputSaveData.songCompletion.get('${songId}') ?? 0.0);
} }
result.setSongScore(songIds[0], 'normal', scoreDataNormal); result.setSongScore(songIds[0], 'normal', scoreDataNormal);
var scoreDataHard:SaveScoreData = var scoreDataHard:SaveScoreData =
{ {
score: 0, score: 0,
accuracy: 0,
tallies: tallies:
{ {
sick: 0, sick: 0,
@ -246,7 +246,7 @@ class SaveDataMigrator
for (songId in songIds) for (songId in songIds)
{ {
scoreDataHard.score = Std.int(Math.max(scoreDataHard.score, inputSaveData.songScores.get('${songId}-hard') ?? 0)); scoreDataHard.score = Std.int(Math.max(scoreDataHard.score, inputSaveData.songScores.get('${songId}-hard') ?? 0));
scoreDataHard.accuracy = Math.max(scoreDataHard.accuracy, inputSaveData.songCompletion.get('${songId}-hard') ?? 0.0); // scoreDataHard.accuracy = Math.max(scoreDataHard.accuracy, inputSaveData.songCompletion.get('${songId}-hard') ?? 0.0);
} }
result.setSongScore(songIds[0], 'hard', scoreDataHard); result.setSongScore(songIds[0], 'hard', scoreDataHard);
} }

View file

@ -137,7 +137,7 @@ using Lambda;
* *
* Some functionality is split into handler classes to help maintain my sanity. * Some functionality is split into handler classes to help maintain my sanity.
* *
* @author MasterEric * @author EliteMasterEric
*/ */
// @:nullSafety // @:nullSafety

View file

@ -38,7 +38,7 @@ class AlbumRoll extends FlxSpriteGroup
var newAlbumArt:FlxAtlasSprite; var newAlbumArt:FlxAtlasSprite;
// var difficultyStars:DifficultyStars; var difficultyStars:DifficultyStars;
var _exitMovers:Null<FreeplayState.ExitMoverData>; var _exitMovers:Null<FreeplayState.ExitMoverData>;
var albumData:Album; var albumData:Album;
@ -65,9 +65,9 @@ class AlbumRoll extends FlxSpriteGroup
add(newAlbumArt); add(newAlbumArt);
// difficultyStars = new DifficultyStars(140, 39); difficultyStars = new DifficultyStars(140, 39);
// difficultyStars.stars.visible = false; difficultyStars.stars.visible = false;
// add(difficultyStars); add(difficultyStars);
} }
function onAlbumFinish(animName:String):Void function onAlbumFinish(animName:String):Void
@ -86,9 +86,14 @@ class AlbumRoll extends FlxSpriteGroup
{ {
if (albumId == null) if (albumId == null)
{ {
// difficultyStars.stars.visible = false; this.visible = false;
difficultyStars.stars.visible = false;
return; return;
} }
else
{
this.visible = true;
}
albumData = AlbumRegistry.instance.fetchEntry(albumId); albumData = AlbumRegistry.instance.fetchEntry(albumId);
@ -144,10 +149,10 @@ class AlbumRoll extends FlxSpriteGroup
newAlbumArt.visible = true; newAlbumArt.visible = true;
newAlbumArt.playAnimation(animNames.get('$albumId-active'), false, false, false); newAlbumArt.playAnimation(animNames.get('$albumId-active'), false, false, false);
// difficultyStars.stars.visible = false; difficultyStars.stars.visible = false;
new FlxTimer().start(0.75, function(_) { new FlxTimer().start(0.75, function(_) {
// showTitle(); // showTitle();
// showStars(); showStars();
}); });
} }
@ -156,16 +161,17 @@ class AlbumRoll extends FlxSpriteGroup
newAlbumArt.playAnimation(animNames.get('$albumId-trans'), false, false, false); newAlbumArt.playAnimation(animNames.get('$albumId-trans'), false, false, false);
} }
// public function setDifficultyStars(?difficulty:Int):Void public function setDifficultyStars(?difficulty:Int):Void
// { {
// if (difficulty == null) return; if (difficulty == null) return;
// difficultyStars.difficulty = difficulty; difficultyStars.difficulty = difficulty;
// } }
// /**
// * Make the album stars visible. /**
// */ * Make the album stars visible.
// public function showStars():Void */
// { public function showStars():Void
// difficultyStars.stars.visible = false; // true; {
// } difficultyStars.stars.visible = true; // true;
}
} }

View file

@ -4,6 +4,12 @@ import openfl.filters.BitmapFilterQuality;
import flixel.text.FlxText; import flixel.text.FlxText;
import flixel.group.FlxSpriteGroup; import flixel.group.FlxSpriteGroup;
import funkin.graphics.shaders.GaussianBlurShader; import funkin.graphics.shaders.GaussianBlurShader;
import funkin.graphics.shaders.LeftMaskShader;
import flixel.math.FlxRect;
import flixel.tweens.FlxEase;
import flixel.util.FlxTimer;
import flixel.tweens.FlxTween;
import openfl.display.BlendMode;
class CapsuleText extends FlxSpriteGroup class CapsuleText extends FlxSpriteGroup
{ {
@ -13,6 +19,15 @@ class CapsuleText extends FlxSpriteGroup
public var text(default, set):String; public var text(default, set):String;
var maskShaderSongName:LeftMaskShader = new LeftMaskShader();
public var clipWidth(default, set):Int = 255;
public var tooLong:Bool = false;
// 255, 27 normal
// 220, 27 favourited
public function new(x:Float, y:Float, songTitle:String, size:Float) public function new(x:Float, y:Float, songTitle:String, size:Float)
{ {
super(x, y); super(x, y);
@ -36,6 +51,30 @@ class CapsuleText extends FlxSpriteGroup
return text; return text;
} }
// ???? none
// 255, 27 normal
// 220, 27 favourited
function set_clipWidth(value:Int):Int
{
resetText();
if (whiteText.width > value)
{
tooLong = true;
blurredText.clipRect = new FlxRect(0, 0, value, blurredText.height);
whiteText.clipRect = new FlxRect(0, 0, value, whiteText.height);
}
else
{
tooLong = false;
blurredText.clipRect = null;
whiteText.clipRect = null;
}
return clipWidth = value;
}
function set_text(value:String):String function set_text(value:String):String
{ {
if (value == null) return value; if (value == null) return value;
@ -51,6 +90,102 @@ class CapsuleText extends FlxSpriteGroup
new openfl.filters.GlowFilter(0x00ccff, 1, 5, 5, 210, BitmapFilterQuality.MEDIUM), new openfl.filters.GlowFilter(0x00ccff, 1, 5, 5, 210, BitmapFilterQuality.MEDIUM),
// new openfl.filters.BlurFilter(5, 5, BitmapFilterQuality.LOW) // new openfl.filters.BlurFilter(5, 5, BitmapFilterQuality.LOW)
]; ];
return text = value; return text = value;
} }
var moveTimer:FlxTimer = new FlxTimer();
var moveTween:FlxTween;
public function initMove():Void
{
moveTimer.start(0.6, (timer) -> {
moveTextRight();
});
}
function moveTextRight():Void
{
var distToMove:Float = whiteText.width - clipWidth;
moveTween = FlxTween.tween(whiteText.offset, {x: distToMove}, 2,
{
onUpdate: function(_) {
whiteText.clipRect = new FlxRect(whiteText.offset.x, 0, clipWidth, whiteText.height);
blurredText.offset = whiteText.offset;
blurredText.clipRect = new FlxRect(whiteText.offset.x, 0, clipWidth, blurredText.height);
},
onComplete: function(_) {
moveTimer.start(0.3, (timer) -> {
moveTextLeft();
});
},
ease: FlxEase.sineInOut
});
}
function moveTextLeft():Void
{
moveTween = FlxTween.tween(whiteText.offset, {x: 0}, 2,
{
onUpdate: function(_) {
whiteText.clipRect = new FlxRect(whiteText.offset.x, 0, clipWidth, whiteText.height);
blurredText.offset = whiteText.offset;
blurredText.clipRect = new FlxRect(whiteText.offset.x, 0, clipWidth, blurredText.height);
},
onComplete: function(_) {
moveTimer.start(0.3, (timer) -> {
moveTextRight();
});
},
ease: FlxEase.sineInOut
});
}
public function resetText():Void
{
if (moveTween != null) moveTween.cancel();
if (moveTimer != null) moveTimer.cancel();
whiteText.offset.x = 0;
whiteText.clipRect = new FlxRect(whiteText.offset.x, 0, clipWidth, whiteText.height);
blurredText.clipRect = new FlxRect(whiteText.offset.x, 0, clipWidth, whiteText.height);
}
var flickerState:Bool = false;
var flickerTimer:FlxTimer;
public function flickerText():Void
{
resetText();
flickerTimer = new FlxTimer().start(1 / 24, flickerProgress, 19);
}
function flickerProgress(timer:FlxTimer):Void
{
if (flickerState == true)
{
whiteText.blend = BlendMode.ADD;
blurredText.blend = BlendMode.ADD;
blurredText.color = 0xFFFFFFFF;
whiteText.color = 0xFFFFFFFF;
whiteText.textField.filters = [
new openfl.filters.GlowFilter(0xFFFFFF, 1, 5, 5, 210, BitmapFilterQuality.MEDIUM),
// new openfl.filters.BlurFilter(5, 5, BitmapFilterQuality.LOW)
];
}
else
{
blurredText.color = 0xFF00aadd;
whiteText.color = 0xFFDDDDDD;
whiteText.textField.filters = [
new openfl.filters.GlowFilter(0xDDDDDD, 1, 5, 5, 210, BitmapFilterQuality.MEDIUM),
// new openfl.filters.BlurFilter(5, 5, BitmapFilterQuality.LOW)
];
}
flickerState = !flickerState;
}
override function update(elapsed:Float):Void
{
super.update(elapsed);
}
} }

View file

@ -82,6 +82,8 @@ class DJBoyfriend extends FlxAtlasSprite
return anims; return anims;
} }
var lowPumpLoopPoint:Int = 4;
public override function update(elapsed:Float):Void public override function update(elapsed:Float):Void
{ {
super.update(elapsed); super.update(elapsed);
@ -114,6 +116,14 @@ class DJBoyfriend extends FlxAtlasSprite
case Confirm: case Confirm:
if (getCurrentAnimation() != 'Boyfriend DJ confirm') playFlashAnimation('Boyfriend DJ confirm', false); if (getCurrentAnimation() != 'Boyfriend DJ confirm') playFlashAnimation('Boyfriend DJ confirm', false);
timeSinceSpook = 0; timeSinceSpook = 0;
case PumpIntro:
if (getCurrentAnimation() != 'Boyfriend DJ fist pump') playFlashAnimation('Boyfriend DJ fist pump', false);
if (getCurrentAnimation() == 'Boyfriend DJ fist pump' && anim.curFrame >= 4)
{
anim.play("Boyfriend DJ fist pump", true, false, 0);
}
case FistPump:
case Spook: case Spook:
if (getCurrentAnimation() != 'bf dj afk') if (getCurrentAnimation() != 'bf dj afk')
{ {
@ -174,6 +184,12 @@ class DJBoyfriend extends FlxAtlasSprite
currentState = Idle; currentState = Idle;
case "Boyfriend DJ confirm": case "Boyfriend DJ confirm":
case "Boyfriend DJ fist pump":
currentState = Idle;
case "Boyfriend DJ loss reaction 1":
currentState = Idle;
case "Boyfriend DJ watchin tv OG": case "Boyfriend DJ watchin tv OG":
var frame:Int = FlxG.random.bool(33) ? 112 : 166; var frame:Int = FlxG.random.bool(33) ? 112 : 166;
@ -275,6 +291,23 @@ class DJBoyfriend extends FlxAtlasSprite
currentState = Confirm; currentState = Confirm;
} }
public function fistPump():Void
{
currentState = PumpIntro;
}
public function pumpFist():Void
{
currentState = FistPump;
anim.play("Boyfriend DJ fist pump", true, false, 4);
}
public function pumpFistBad():Void
{
currentState = FistPump;
anim.play("Boyfriend DJ loss reaction 1", true, false, 4);
}
public inline function addOffset(name:String, x:Float = 0, y:Float = 0) public inline function addOffset(name:String, x:Float = 0, y:Float = 0)
{ {
animOffsets[name] = [x, y]; animOffsets[name] = [x, y];
@ -331,6 +364,8 @@ enum DJBoyfriendState
Intro; Intro;
Idle; Idle;
Confirm; Confirm;
PumpIntro;
FistPump;
Spook; Spook;
TV; TV;
} }

View file

@ -0,0 +1,106 @@
package funkin.ui.freeplay;
import flixel.group.FlxSpriteGroup;
import funkin.graphics.adobeanimate.FlxAtlasSprite;
import funkin.graphics.shaders.HSVShader;
class DifficultyStars extends FlxSpriteGroup
{
/**
* Internal handler var for difficulty... ranges from 0... to 15
* 0 is 1 star... 15 is 0 stars!
*/
var curDifficulty(default, set):Int = 0;
/**
* Range between 0 and 15
*/
public var difficulty(default, set):Int = 1;
public var stars:FlxAtlasSprite;
var flames:FreeplayFlames;
var hsvShader:HSVShader;
public function new(x:Float, y:Float)
{
super(x, y);
hsvShader = new HSVShader();
flames = new FreeplayFlames(0, 0);
add(flames);
stars = new FlxAtlasSprite(0, 0, Paths.animateAtlas("freeplay/freeplayStars"));
stars.anim.play("diff stars");
add(stars);
stars.shader = hsvShader;
for (memb in flames.members)
memb.shader = hsvShader;
}
override function update(elapsed:Float):Void
{
super.update(elapsed);
// "loops" the current animation
// for clarity, the animation file looks like
// frame : stars
// 0-99: 1 star
// 100-199: 2 stars
// ......
// 1300-1499: 15 stars
// 1500 : 0 stars
if (curDifficulty < 15 && stars.anim.curFrame >= (curDifficulty + 1) * 100)
{
stars.anim.play("diff stars", true, false, curDifficulty * 100);
}
}
function set_difficulty(value:Int):Int
{
difficulty = value;
if (difficulty <= 0)
{
difficulty = 0;
curDifficulty = 15;
}
else if (difficulty <= 15)
{
difficulty = value;
curDifficulty = difficulty - 1;
}
else
{
difficulty = 15;
curDifficulty = difficulty - 1;
}
if (difficulty > 10) flames.flameCount = difficulty - 10;
else
flames.flameCount = 0;
return difficulty;
}
function set_curDifficulty(value:Int):Int
{
curDifficulty = value;
if (curDifficulty == 15)
{
stars.anim.play("diff stars", true, false, 1500);
stars.anim.pause();
}
else
{
stars.anim.curFrame = Std.int(curDifficulty * 100);
stars.anim.play("diff stars", true, false, curDifficulty * 100);
}
return curDifficulty;
}
}

View file

@ -50,8 +50,19 @@ class FreeplayFlames extends FlxSpriteGroup
} }
} }
var timers:Array<FlxTimer> = [];
function set_flameCount(value:Int):Int function set_flameCount(value:Int):Int
{ {
// Stop all existing timers.
// This fixes a bug where quickly switching difficulties would show flames.
for (timer in timers)
{
timer.active = false;
timer.destroy();
timers.remove(timer);
}
this.flameCount = value; this.flameCount = value;
var visibleCount:Int = 0; var visibleCount:Int = 0;
for (i in 0...5) for (i in 0...5)
@ -62,10 +73,18 @@ class FreeplayFlames extends FlxSpriteGroup
{ {
if (!flame.visible) if (!flame.visible)
{ {
new FlxTimer().start(flameTimer * visibleCount, function(_) { var nextTimer:FlxTimer = new FlxTimer().start(flameTimer * visibleCount, function(currentTimer:FlxTimer) {
if (i >= this.flameCount)
{
trace('EARLY EXIT');
return;
}
timers.remove(currentTimer);
flame.animation.play("flame", true); flame.animation.play("flame", true);
flame.visible = true; flame.visible = true;
}); });
timers.push(nextTimer);
visibleCount++; visibleCount++;
} }
} }

View file

@ -1,5 +1,6 @@
package funkin.ui.freeplay; package funkin.ui.freeplay;
import funkin.graphics.adobeanimate.FlxAtlasSprite;
import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.ui.FlxInputText; import flixel.addons.ui.FlxInputText;
import flixel.FlxCamera; import flixel.FlxCamera;
@ -10,6 +11,7 @@ import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.input.touch.FlxTouch; import flixel.input.touch.FlxTouch;
import flixel.math.FlxAngle; import flixel.math.FlxAngle;
import flixel.math.FlxPoint; import flixel.math.FlxPoint;
import openfl.display.BlendMode;
import flixel.system.debug.watch.Tracker.TrackerProfile; import flixel.system.debug.watch.Tracker.TrackerProfile;
import flixel.text.FlxText; import flixel.text.FlxText;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
@ -38,6 +40,8 @@ import funkin.ui.transition.LoadingState;
import funkin.ui.transition.StickerSubState; import funkin.ui.transition.StickerSubState;
import funkin.util.MathUtil; import funkin.util.MathUtil;
import lime.utils.Assets; import lime.utils.Assets;
import flixel.tweens.misc.ShakeTween;
import funkin.effects.IntervalShake;
/** /**
* Parameters used to initialize the FreeplayState. * Parameters used to initialize the FreeplayState.
@ -120,8 +124,6 @@ class FreeplayState extends MusicBeatSubState
var curCapsule:SongMenuItem; var curCapsule:SongMenuItem;
var curPlaying:Bool = false; var curPlaying:Bool = false;
var displayedVariations:Array<String>;
var dj:DJBoyfriend; var dj:DJBoyfriend;
var ostName:FlxText; var ostName:FlxText;
@ -135,6 +137,29 @@ class FreeplayState extends MusicBeatSubState
public static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY; public static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
public static var rememberedSongId:Null<String> = 'tutorial'; public static var rememberedSongId:Null<String> = 'tutorial';
var funnyCam:FunkinCamera;
var rankCamera:FunkinCamera;
var rankBg:FunkinSprite;
var rankVignette:FlxSprite;
var backingTextYeah:FlxAtlasSprite;
var orangeBackShit:FunkinSprite;
var alsoOrangeLOL:FunkinSprite;
var pinkBack:FunkinSprite;
var confirmGlow:FlxSprite;
var confirmGlow2:FlxSprite;
var confirmTextGlow:FlxSprite;
var moreWays:BGScrollingText;
var funnyScroll:BGScrollingText;
var txtNuts:BGScrollingText;
var funnyScroll2:BGScrollingText;
var moreWays2:BGScrollingText;
var funnyScroll3:BGScrollingText;
var bgDad:FlxSprite;
var cardGlow:FlxSprite;
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState) public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
{ {
currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER; currentCharacter = params?.character ?? Constants.DEFAULT_CHARACTER;
@ -184,10 +209,6 @@ 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.listSortedLevelIds()) for (levelId in LevelRegistry.instance.listSortedLevelIds())
{ {
@ -195,7 +216,8 @@ class FreeplayState extends MusicBeatSubState
{ {
var song:Song = SongRegistry.instance.fetchEntry(songId); var song:Song = SongRegistry.instance.fetchEntry(songId);
// Only display songs which actually have available charts for the current character. // Only display songs which actually have available difficulties for the current character.
var displayedVariations = song.getVariationsByCharId(currentCharacter);
var availableDifficultiesForSong:Array<String> = song.listDifficulties(displayedVariations, false); var availableDifficultiesForSong:Array<String> = song.listDifficulties(displayedVariations, false);
if (availableDifficultiesForSong.length == 0) continue; if (availableDifficultiesForSong.length == 0) continue;
@ -216,17 +238,17 @@ class FreeplayState extends MusicBeatSubState
trace(FlxG.camera.initialZoom); trace(FlxG.camera.initialZoom);
trace(FlxCamera.defaultZoom); trace(FlxCamera.defaultZoom);
var pinkBack:FunkinSprite = FunkinSprite.create('freeplay/pinkBack'); pinkBack = FunkinSprite.create('freeplay/pinkBack');
pinkBack.color = 0xFFFFD4E9; // sets it to pink! pinkBack.color = 0xFFFFD4E9; // sets it to pink!
pinkBack.x -= pinkBack.width; pinkBack.x -= pinkBack.width;
FlxTween.tween(pinkBack, {x: 0}, 0.6, {ease: FlxEase.quartOut}); FlxTween.tween(pinkBack, {x: 0}, 0.6, {ease: FlxEase.quartOut});
add(pinkBack); add(pinkBack);
var orangeBackShit:FunkinSprite = new FunkinSprite(84, 440).makeSolidColor(Std.int(pinkBack.width), 75, 0xFFFEDA00); orangeBackShit = new FunkinSprite(84, 440).makeSolidColor(Std.int(pinkBack.width), 75, 0xFFFEDA00);
add(orangeBackShit); add(orangeBackShit);
var alsoOrangeLOL:FunkinSprite = new FunkinSprite(0, orangeBackShit.y).makeSolidColor(100, Std.int(orangeBackShit.height), 0xFFFFD400); alsoOrangeLOL = new FunkinSprite(0, orangeBackShit.y).makeSolidColor(100, Std.int(orangeBackShit.height), 0xFFFFD400);
add(alsoOrangeLOL); add(alsoOrangeLOL);
exitMovers.set([pinkBack, orangeBackShit, alsoOrangeLOL], exitMovers.set([pinkBack, orangeBackShit, alsoOrangeLOL],
@ -241,13 +263,30 @@ class FreeplayState extends MusicBeatSubState
orangeBackShit.visible = false; orangeBackShit.visible = false;
alsoOrangeLOL.visible = false; alsoOrangeLOL.visible = false;
confirmTextGlow = new FlxSprite(-8, 115).loadGraphic(Paths.image('freeplay/glowingText'));
confirmTextGlow.blend = BlendMode.ADD;
confirmTextGlow.visible = false;
confirmGlow = new FlxSprite(-30, 240).loadGraphic(Paths.image('freeplay/confirmGlow'));
confirmGlow.blend = BlendMode.ADD;
confirmGlow2 = new FlxSprite(confirmGlow.x, confirmGlow.y).loadGraphic(Paths.image('freeplay/confirmGlow2'));
confirmGlow.visible = false;
confirmGlow2.visible = false;
add(confirmGlow2);
add(confirmGlow);
add(confirmTextGlow);
var grpTxtScrolls:FlxGroup = new FlxGroup(); var grpTxtScrolls:FlxGroup = new FlxGroup();
add(grpTxtScrolls); add(grpTxtScrolls);
grpTxtScrolls.visible = false; grpTxtScrolls.visible = false;
FlxG.debugger.addTrackerProfile(new TrackerProfile(BGScrollingText, ['x', 'y', 'speed', 'size'])); FlxG.debugger.addTrackerProfile(new TrackerProfile(BGScrollingText, ['x', 'y', 'speed', 'size']));
var moreWays:BGScrollingText = new BGScrollingText(0, 160, 'HOT BLOODED IN MORE WAYS THAN ONE', FlxG.width, true, 43); moreWays = new BGScrollingText(0, 160, 'HOT BLOODED IN MORE WAYS THAN ONE', FlxG.width, true, 43);
moreWays.funnyColor = 0xFFFFF383; moreWays.funnyColor = 0xFFFFF383;
moreWays.speed = 6.8; moreWays.speed = 6.8;
grpTxtScrolls.add(moreWays); grpTxtScrolls.add(moreWays);
@ -258,7 +297,7 @@ class FreeplayState extends MusicBeatSubState
speed: 0.4, speed: 0.4,
}); });
var funnyScroll:BGScrollingText = new BGScrollingText(0, 220, 'BOYFRIEND', FlxG.width / 2, false, 60); funnyScroll = new BGScrollingText(0, 220, 'BOYFRIEND', FlxG.width / 2, false, 60);
funnyScroll.funnyColor = 0xFFFF9963; funnyScroll.funnyColor = 0xFFFF9963;
funnyScroll.speed = -3.8; funnyScroll.speed = -3.8;
grpTxtScrolls.add(funnyScroll); grpTxtScrolls.add(funnyScroll);
@ -271,7 +310,7 @@ class FreeplayState extends MusicBeatSubState
wait: 0 wait: 0
}); });
var txtNuts:BGScrollingText = new BGScrollingText(0, 285, 'PROTECT YO NUTS', FlxG.width / 2, true, 43); txtNuts = new BGScrollingText(0, 285, 'PROTECT YO NUTS', FlxG.width / 2, true, 43);
txtNuts.speed = 3.5; txtNuts.speed = 3.5;
grpTxtScrolls.add(txtNuts); grpTxtScrolls.add(txtNuts);
exitMovers.set([txtNuts], exitMovers.set([txtNuts],
@ -280,7 +319,7 @@ class FreeplayState extends MusicBeatSubState
speed: 0.4, speed: 0.4,
}); });
var funnyScroll2:BGScrollingText = new BGScrollingText(0, 335, 'BOYFRIEND', FlxG.width / 2, false, 60); funnyScroll2 = new BGScrollingText(0, 335, 'BOYFRIEND', FlxG.width / 2, false, 60);
funnyScroll2.funnyColor = 0xFFFF9963; funnyScroll2.funnyColor = 0xFFFF9963;
funnyScroll2.speed = -3.8; funnyScroll2.speed = -3.8;
grpTxtScrolls.add(funnyScroll2); grpTxtScrolls.add(funnyScroll2);
@ -291,7 +330,7 @@ class FreeplayState extends MusicBeatSubState
speed: 0.5, speed: 0.5,
}); });
var moreWays2:BGScrollingText = new BGScrollingText(0, 397, 'HOT BLOODED IN MORE WAYS THAN ONE', FlxG.width, true, 43); moreWays2 = new BGScrollingText(0, 397, 'HOT BLOODED IN MORE WAYS THAN ONE', FlxG.width, true, 43);
moreWays2.funnyColor = 0xFFFFF383; moreWays2.funnyColor = 0xFFFFF383;
moreWays2.speed = 6.8; moreWays2.speed = 6.8;
grpTxtScrolls.add(moreWays2); grpTxtScrolls.add(moreWays2);
@ -302,7 +341,7 @@ class FreeplayState extends MusicBeatSubState
speed: 0.4 speed: 0.4
}); });
var funnyScroll3:BGScrollingText = new BGScrollingText(0, orangeBackShit.y + 10, 'BOYFRIEND', FlxG.width / 2, 60); funnyScroll3 = new BGScrollingText(0, orangeBackShit.y + 10, 'BOYFRIEND', FlxG.width / 2, 60);
funnyScroll3.funnyColor = 0xFFFEA400; funnyScroll3.funnyColor = 0xFFFEA400;
funnyScroll3.speed = -3.8; funnyScroll3.speed = -3.8;
grpTxtScrolls.add(funnyScroll3); grpTxtScrolls.add(funnyScroll3);
@ -313,6 +352,24 @@ class FreeplayState extends MusicBeatSubState
speed: 0.3 speed: 0.3
}); });
backingTextYeah = new FlxAtlasSprite(640, 370, Paths.animateAtlas("freeplay/backing-text-yeah"),
{
FrameRate: 24.0,
Reversed: false,
// ?OnComplete:Void -> Void,
ShowPivot: false,
Antialiasing: true,
ScrollFactor: new FlxPoint(1, 1),
});
add(backingTextYeah);
cardGlow = new FlxSprite(-30, -30).loadGraphic(Paths.image('freeplay/cardGlow'));
cardGlow.blend = BlendMode.ADD;
cardGlow.visible = false;
add(cardGlow);
dj = new DJBoyfriend(640, 366); dj = new DJBoyfriend(640, 366);
exitMovers.set([dj], exitMovers.set([dj],
{ {
@ -325,7 +382,7 @@ class FreeplayState extends MusicBeatSubState
add(dj); add(dj);
var bgDad:FlxSprite = new FlxSprite(pinkBack.width * 0.75, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad')); bgDad = new FlxSprite(pinkBack.width * 0.75, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad'));
bgDad.setGraphicSize(0, FlxG.height); bgDad.setGraphicSize(0, FlxG.height);
bgDad.updateHitbox(); bgDad.updateHitbox();
bgDad.shader = new AngleMask(); bgDad.shader = new AngleMask();
@ -342,10 +399,14 @@ class FreeplayState extends MusicBeatSubState
}); });
add(bgDad); add(bgDad);
FlxTween.tween(blackOverlayBullshitLOLXD, {x: pinkBack.width * 0.75}, 0.7, {ease: FlxEase.quintOut}); FlxTween.tween(blackOverlayBullshitLOLXD, {x: pinkBack.width * 0.76}, 0.7, {ease: FlxEase.quintOut});
blackOverlayBullshitLOLXD.shader = bgDad.shader; blackOverlayBullshitLOLXD.shader = bgDad.shader;
rankBg = new FunkinSprite(0, 0);
rankBg.makeSolidColor(FlxG.width, FlxG.height, 0xD3000000);
add(rankBg);
grpSongs = new FlxTypedGroup<Alphabet>(); grpSongs = new FlxTypedGroup<Alphabet>();
add(grpSongs); add(grpSongs);
@ -488,10 +549,6 @@ class FreeplayState extends MusicBeatSubState
albumRoll.playIntro(); albumRoll.playIntro();
new FlxTimer().start(0.75, function(_) {
// albumRoll.showTitle();
});
FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut}); FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut});
diffSelLeft.visible = true; diffSelLeft.visible = true;
@ -527,18 +584,35 @@ class FreeplayState extends MusicBeatSubState
orangeBackShit.visible = true; orangeBackShit.visible = true;
alsoOrangeLOL.visible = true; alsoOrangeLOL.visible = true;
grpTxtScrolls.visible = true; grpTxtScrolls.visible = true;
cardGlow.visible = true;
FlxTween.tween(cardGlow, {alpha: 0, "scale.x": 1.2, "scale.y": 1.2}, 0.45, {ease: FlxEase.sineOut});
}); });
generateSongList(null, false); generateSongList(null, false);
// dedicated camera for the state so we don't need to fuk around with camera scrolls from the mainmenu / elsewhere // dedicated camera for the state so we don't need to fuk around with camera scrolls from the mainmenu / elsewhere
var funnyCam:FunkinCamera = new FunkinCamera('freeplayFunny', 0, 0, FlxG.width, FlxG.height); funnyCam = new FunkinCamera('freeplayFunny', 0, 0, FlxG.width, FlxG.height);
funnyCam.bgColor = FlxColor.TRANSPARENT; funnyCam.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(funnyCam, false); FlxG.cameras.add(funnyCam, false);
rankVignette = new FlxSprite(0, 0).loadGraphic(Paths.image('freeplay/rankVignette'));
rankVignette.scale.set(2, 2);
rankVignette.updateHitbox();
rankVignette.blend = BlendMode.ADD;
// rankVignette.cameras = [rankCamera];
add(rankVignette);
rankVignette.alpha = 0;
forEach(function(bs) { forEach(function(bs) {
bs.cameras = [funnyCam]; bs.cameras = [funnyCam];
}); });
rankCamera = new FunkinCamera('rankCamera', 0, 0, FlxG.width, FlxG.height);
rankCamera.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(rankCamera, false);
rankBg.cameras = [rankCamera];
rankBg.alpha = 0;
} }
var currentFilter:SongFilter = null; var currentFilter:SongFilter = null;
@ -585,6 +659,7 @@ class FreeplayState extends MusicBeatSubState
for (cap in grpCapsules.members) for (cap in grpCapsules.members)
{ {
cap.songText.resetText();
cap.kill(); cap.kill();
} }
@ -602,9 +677,11 @@ class FreeplayState extends MusicBeatSubState
}; };
randomCapsule.y = randomCapsule.intendedY(0) + 10; randomCapsule.y = randomCapsule.intendedY(0) + 10;
randomCapsule.targetPos.x = randomCapsule.x; randomCapsule.targetPos.x = randomCapsule.x;
randomCapsule.alpha = 0.5; randomCapsule.alpha = 0;
randomCapsule.songText.visible = false; randomCapsule.songText.visible = false;
randomCapsule.favIcon.visible = false; randomCapsule.favIcon.visible = false;
randomCapsule.ranking.visible = false;
randomCapsule.blurredRanking.visible = false;
randomCapsule.initJumpIn(0, force); randomCapsule.initJumpIn(0, force);
randomCapsule.hsvShader = hsvShader; randomCapsule.hsvShader = hsvShader;
grpCapsules.add(randomCapsule); grpCapsules.add(randomCapsule);
@ -627,8 +704,12 @@ class FreeplayState extends MusicBeatSubState
funnyMenu.favIcon.visible = tempSongs[i].isFav; funnyMenu.favIcon.visible = tempSongs[i].isFav;
funnyMenu.hsvShader = hsvShader; funnyMenu.hsvShader = hsvShader;
funnyMenu.newText.animation.curAnim.curFrame = 45 - ((i * 4) % 45);
funnyMenu.forcePosition(); funnyMenu.forcePosition();
funnyMenu.checkClip();
grpCapsules.add(funnyMenu); grpCapsules.add(funnyMenu);
} }
@ -682,6 +763,210 @@ class FreeplayState extends MusicBeatSubState
return songsToFilter; return songsToFilter;
} }
function rankAnimStart()
{
dj.fistPump();
// rankCamera.fade(FlxColor.BLACK, 0.5, true);
rankCamera.fade(0xFF000000, 0.5, true, null, true);
FlxG.sound.music.volume = 0;
rankBg.alpha = 1;
originalPos.x = grpCapsules.members[curSelected].x;
originalPos.y = grpCapsules.members[curSelected].y;
grpCapsules.members[curSelected].ranking.alpha = 0;
grpCapsules.members[curSelected].blurredRanking.alpha = 0;
rankCamera.zoom = 1.85;
FlxTween.tween(rankCamera, {"zoom": 1.8}, 0.6, {ease: FlxEase.sineIn});
funnyCam.zoom = 1.15;
FlxTween.tween(funnyCam, {"zoom": 1.1}, 0.6, {ease: FlxEase.sineIn});
grpCapsules.members[curSelected].cameras = [rankCamera];
grpCapsules.members[curSelected].targetPos.set((FlxG.width / 2) - (grpCapsules.members[curSelected].width / 2),
(FlxG.height / 2) - (grpCapsules.members[curSelected].height / 2));
new FlxTimer().start(0.5, _ -> {
grpCapsules.members[curSelected].doLerp = false;
rankDisplayNew();
});
}
function rankDisplayNew()
{
grpCapsules.members[curSelected].ranking.alpha = 1;
grpCapsules.members[curSelected].blurredRanking.alpha = 1;
grpCapsules.members[curSelected].ranking.scale.set(20, 20);
grpCapsules.members[curSelected].blurredRanking.scale.set(20, 20);
// var tempr:Int = FlxG.random.int(0, 4);
// grpCapsules.members[curSelected].ranking.rank = tempr;
grpCapsules.members[curSelected].ranking.animation.play(grpCapsules.members[curSelected].ranking.animation.curAnim.name, true);
FlxTween.tween(grpCapsules.members[curSelected].ranking, {"scale.x": 1, "scale.y": 1}, 0.1);
grpCapsules.members[curSelected].blurredRanking.animation.play(grpCapsules.members[curSelected].blurredRanking.animation.curAnim.name, true);
FlxTween.tween(grpCapsules.members[curSelected].blurredRanking, {"scale.x": 1, "scale.y": 1}, 0.1);
new FlxTimer().start(0.1, _ -> {
trace(grpCapsules.members[curSelected].ranking.rank);
switch (grpCapsules.members[curSelected].tempr)
{
case 0:
FunkinSound.playOnce(Paths.sound('ranks/rankinbad'));
case 4:
FunkinSound.playOnce(Paths.sound('ranks/rankinperfect'));
case 5:
FunkinSound.playOnce(Paths.sound('ranks/rankinperfect'));
default:
FunkinSound.playOnce(Paths.sound('ranks/rankinnormal'));
}
rankCamera.zoom = 1.3;
// FlxTween.tween(rankCamera, {"zoom": 1.4}, 0.3, {ease: FlxEase.elasticOut});
FlxTween.tween(rankCamera, {"zoom": 1.5}, 0.3, {ease: FlxEase.backInOut});
grpCapsules.members[curSelected].x -= 10;
grpCapsules.members[curSelected].y -= 20;
FlxTween.tween(funnyCam, {"zoom": 1.05}, 0.3, {ease: FlxEase.elasticOut});
grpCapsules.members[curSelected].capsule.angle = -3;
FlxTween.tween(grpCapsules.members[curSelected].capsule, {angle: 0}, 0.5, {ease: FlxEase.backOut});
IntervalShake.shake(grpCapsules.members[curSelected].capsule, 0.3, 1 / 30, 0.1, 0, FlxEase.quadOut);
});
new FlxTimer().start(0.4, _ -> {
FlxTween.tween(funnyCam, {"zoom": 1}, 0.8, {ease: FlxEase.sineIn});
FlxTween.tween(rankCamera, {"zoom": 1.2}, 0.8, {ease: FlxEase.backIn});
// IntervalShake.shake(grpCapsules.members[curSelected], 0.8 + 0.5, 1 / 24, 0, 2, FlxEase.quadIn);
FlxTween.tween(grpCapsules.members[curSelected], {x: originalPos.x - 7, y: originalPos.y - 80}, 0.8 + 0.5, {ease: FlxEase.quartIn});
});
new FlxTimer().start(0.6, _ -> {
rankAnimSlam();
// IntervalShake.shake(grpCapsules.members[curSelected].capsule, 0.3, 1 / 30, 0, 0.3, FlxEase.quartIn);
});
}
function rankAnimSlam()
{
// FlxTween.tween(rankCamera, {"zoom": 1.9}, 0.5, {ease: FlxEase.backOut});
FlxTween.tween(rankBg, {alpha: 0}, 0.5, {ease: FlxEase.expoIn});
// FlxTween.tween(grpCapsules.members[curSelected], {angle: 5}, 0.5, {ease: FlxEase.backIn});
switch (grpCapsules.members[curSelected].tempr)
{
case 0:
FunkinSound.playOnce(Paths.sound('ranks/loss'));
case 1:
FunkinSound.playOnce(Paths.sound('ranks/good'));
case 2:
FunkinSound.playOnce(Paths.sound('ranks/great'));
case 3:
FunkinSound.playOnce(Paths.sound('ranks/excellent'));
case 4:
FunkinSound.playOnce(Paths.sound('ranks/perfect'));
case 5:
FunkinSound.playOnce(Paths.sound('ranks/perfect'));
default:
FunkinSound.playOnce(Paths.sound('ranks/loss'));
}
FlxTween.tween(grpCapsules.members[curSelected], {"targetPos.x": originalPos.x, "targetPos.y": originalPos.y}, 0.5, {ease: FlxEase.expoOut});
new FlxTimer().start(0.5, _ -> {
funnyCam.shake(0.0045, 0.35);
if (grpCapsules.members[curSelected].tempr == 0)
{
dj.pumpFistBad();
}
else
{
dj.pumpFist();
}
rankCamera.zoom = 0.8;
funnyCam.zoom = 0.8;
FlxTween.tween(rankCamera, {"zoom": 1}, 1, {ease: FlxEase.elasticOut});
FlxTween.tween(funnyCam, {"zoom": 1}, 0.8, {ease: FlxEase.elasticOut});
for (index => capsule in grpCapsules.members)
{
var distFromSelected:Float = Math.abs(index - curSelected) - 1;
if (distFromSelected < 5)
{
if (index == curSelected)
{
FlxTween.cancelTweensOf(capsule);
// capsule.targetPos.x += 50;
capsule.fadeAnim();
rankVignette.color = capsule.getTrailColor();
rankVignette.alpha = 1;
FlxTween.tween(rankVignette, {alpha: 0}, 0.6, {ease: FlxEase.expoOut});
capsule.doLerp = false;
capsule.setPosition(originalPos.x, originalPos.y);
IntervalShake.shake(capsule, 0.6, 1 / 24, 0.12, 0, FlxEase.quadOut, function(_) {
capsule.doLerp = true;
capsule.cameras = [funnyCam];
}, null);
// FlxTween.tween(capsule, {"targetPos.x": capsule.targetPos.x - 50}, 0.6,
// {
// ease: FlxEase.backInOut,
// onComplete: function(_) {
// capsule.cameras = [funnyCam];
// }
// });
FlxTween.tween(capsule, {angle: 0}, 0.5, {ease: FlxEase.backOut});
}
if (index > curSelected)
{
// capsule.color = FlxColor.RED;
new FlxTimer().start(distFromSelected / 20, _ -> {
capsule.doLerp = false;
capsule.capsule.angle = FlxG.random.float(-10 + (distFromSelected * 2), 10 - (distFromSelected * 2));
FlxTween.tween(capsule.capsule, {angle: 0}, 0.5, {ease: FlxEase.backOut});
IntervalShake.shake(capsule, 0.6, 1 / 24, 0.12 / (distFromSelected + 1), 0, FlxEase.quadOut, function(_) {
capsule.doLerp = true;
});
});
}
if (index < curSelected)
{
// capsule.color = FlxColor.BLUE;
new FlxTimer().start(distFromSelected / 20, _ -> {
capsule.doLerp = false;
capsule.capsule.angle = FlxG.random.float(-10 + (distFromSelected * 2), 10 - (distFromSelected * 2));
FlxTween.tween(capsule.capsule, {angle: 0}, 0.5, {ease: FlxEase.backOut});
IntervalShake.shake(capsule, 0.6, 1 / 24, 0.12 / (distFromSelected + 1), 0, FlxEase.quadOut, function(_) {
capsule.doLerp = true;
});
});
}
}
index += 1;
}
});
new FlxTimer().start(2, _ -> {
// dj.fistPump();
FlxG.sound.music.fadeIn(4.0, 0.0, 1.0);
});
}
var touchY:Float = 0; var touchY:Float = 0;
var touchX:Float = 0; var touchX:Float = 0;
var dxTouch:Float = 0; var dxTouch:Float = 0;
@ -698,18 +983,56 @@ class FreeplayState extends MusicBeatSubState
var busy:Bool = false; // Set to true once the user has pressed enter to select a song. var busy:Bool = false; // Set to true once the user has pressed enter to select a song.
var originalPos:FlxPoint = new FlxPoint();
override function update(elapsed:Float):Void override function update(elapsed:Float):Void
{ {
super.update(elapsed); super.update(elapsed);
if (FlxG.keys.justPressed.T)
{
rankAnimStart();
}
if (FlxG.keys.justPressed.H)
{
rankDisplayNew();
}
if (FlxG.keys.justPressed.G)
{
rankAnimSlam();
}
if (FlxG.keys.justPressed.I)
{
confirmTextGlow.y -= 1;
trace(confirmTextGlow.x, confirmTextGlow.y);
}
if (FlxG.keys.justPressed.J)
{
confirmTextGlow.x -= 1;
trace(confirmTextGlow.x, confirmTextGlow.y);
}
if (FlxG.keys.justPressed.L)
{
confirmTextGlow.x += 1;
trace(confirmTextGlow.x, confirmTextGlow.y);
}
if (FlxG.keys.justPressed.K)
{
confirmTextGlow.y += 1;
trace(confirmTextGlow.x, confirmTextGlow.y);
}
if (FlxG.keys.justPressed.F) if (FlxG.keys.justPressed.F)
{ {
var targetSong = grpCapsules.members[curSelected]?.songData; var targetSong = grpCapsules.members[curSelected]?.songData;
if (targetSong != null) if (targetSong != null)
{ {
var realShit:Int = curSelected; var realShit:Int = curSelected;
targetSong.isFav = !targetSong.isFav; var isFav = targetSong.toggleFavorite();
if (targetSong.isFav) if (isFav)
{ {
FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4, FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4,
{ {
@ -1021,7 +1344,7 @@ class FreeplayState extends MusicBeatSubState
{ {
var songScore:SaveScoreData = Save.instance.getSongScore(grpCapsules.members[curSelected].songData.songId, currentDifficulty); var songScore:SaveScoreData = Save.instance.getSongScore(grpCapsules.members[curSelected].songData.songId, currentDifficulty);
intendedScore = songScore?.score ?? 0; intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore?.accuracy ?? 0.0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
rememberedDifficulty = currentDifficulty; rememberedDifficulty = currentDifficulty;
} }
else else
@ -1086,6 +1409,9 @@ class FreeplayState extends MusicBeatSubState
albumRoll.albumId = newAlbumId; albumRoll.albumId = newAlbumId;
albumRoll.skipIntro(); albumRoll.skipIntro();
} }
// Set difficulty star count.
albumRoll.setDifficultyStars(daSong?.difficultyRating);
} }
// Clears the cache of songs, frees up memory, they' ll have to be loaded in later tho function clearDaCache(actualSongTho:String) // Clears the cache of songs, frees up memory, they' ll have to be loaded in later tho function clearDaCache(actualSongTho:String)
@ -1159,6 +1485,42 @@ class FreeplayState extends MusicBeatSubState
FunkinSound.playOnce(Paths.sound('confirmMenu')); FunkinSound.playOnce(Paths.sound('confirmMenu'));
dj.confirm(); dj.confirm();
grpCapsules.members[curSelected].songText.flickerText();
// FlxTween.color(bgDad, 0.33, 0xFFFFFFFF, 0xFF555555, {ease: FlxEase.quadOut});
FlxTween.color(pinkBack, 0.33, 0xFFFFD0D5, 0xFF171831, {ease: FlxEase.quadOut});
orangeBackShit.visible = false;
alsoOrangeLOL.visible = false;
confirmGlow.visible = true;
confirmGlow2.visible = true;
backingTextYeah.anim.play("BF back card confirm raw", false, false, 0);
confirmGlow2.alpha = 0;
confirmGlow.alpha = 0;
FlxTween.tween(confirmGlow2, {alpha: 0.5}, 0.33,
{
ease: FlxEase.quadOut,
onComplete: function(_) {
confirmGlow2.alpha = 0.6;
confirmGlow.alpha = 1;
confirmTextGlow.visible = true;
confirmTextGlow.alpha = 1;
FlxTween.tween(confirmTextGlow, {alpha: 0.4}, 0.5);
FlxTween.tween(confirmGlow, {alpha: 0}, 0.5);
}
});
// confirmGlow
moreWays.visible = false;
funnyScroll.visible = false;
txtNuts.visible = false;
funnyScroll2.visible = false;
moreWays2.visible = false;
funnyScroll3.visible = false;
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.loadPlayState( LoadingState.loadPlayState(
@ -1216,7 +1578,7 @@ class FreeplayState extends MusicBeatSubState
{ {
var songScore:SaveScoreData = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty); var songScore:SaveScoreData = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty);
intendedScore = songScore?.score ?? 0; intendedScore = songScore?.score ?? 0;
intendedCompletion = songScore?.accuracy ?? 0.0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes);
diffIdsCurrent = daSongCapsule.songData.songDifficulties; diffIdsCurrent = daSongCapsule.songData.songDifficulties;
rememberedSongId = daSongCapsule.songData.songId; rememberedSongId = daSongCapsule.songData.songId;
changeDiff(); changeDiff();
@ -1397,11 +1759,13 @@ class FreeplaySongData
public var songName(default, null):String = ''; public var songName(default, null):String = '';
public var songCharacter(default, null):String = ''; public var songCharacter(default, null):String = '';
public var songRating(default, null):Int = 0; public var songStartingBpm(default, null):Float = 0;
public var difficultyRating(default, null):Int = 0;
public var albumId(default, null):Null<String> = null; public var albumId(default, null):Null<String> = null;
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];
var displayedVariations:Array<String> = [Constants.DEFAULT_VARIATION];
function set_currentDifficulty(value:String):String function set_currentDifficulty(value:String):String
{ {
@ -1417,11 +1781,32 @@ class FreeplaySongData
this.levelId = levelId; this.levelId = levelId;
this.songId = songId; this.songId = songId;
this.song = song; this.song = song;
this.isFav = Save.instance.isSongFavorited(songId);
if (displayedVariations != null) this.displayedVariations = displayedVariations; if (displayedVariations != null) this.displayedVariations = displayedVariations;
updateValues(displayedVariations); updateValues(displayedVariations);
} }
/**
* Toggle whether or not the song is favorited, then flush to save data.
* @return Whether or not the song is now favorited.
*/
public function toggleFavorite():Bool
{
isFav = !isFav;
if (isFav)
{
Save.instance.favoriteSong(this.songId);
}
else
{
Save.instance.unfavoriteSong(this.songId);
}
return isFav;
}
function updateValues(variations:Array<String>):Void function updateValues(variations:Array<String>):Void
{ {
this.songDifficulties = song.listDifficulties(variations, false, false); this.songDifficulties = song.listDifficulties(variations, false, false);
@ -1429,9 +1814,10 @@ class FreeplaySongData
var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, variations); var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, variations);
if (songDifficulty == null) return; if (songDifficulty == null) return;
this.songStartingBpm = songDifficulty.getStartingBPM();
this.songName = songDifficulty.songName; this.songName = songDifficulty.songName;
this.songCharacter = songDifficulty.characters.opponent; this.songCharacter = songDifficulty.characters.opponent;
this.songRating = songDifficulty.difficultyRating; this.difficultyRating = songDifficulty.difficultyRating;
if (songDifficulty.album == null) if (songDifficulty.album == null)
{ {
FlxG.log.warn('No album for: ${songDifficulty.songName}'); FlxG.log.warn('No album for: ${songDifficulty.songName}');

View file

@ -14,6 +14,13 @@ import flixel.text.FlxText;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
import funkin.util.MathUtil; import funkin.util.MathUtil;
import funkin.graphics.shaders.Grayscale; import funkin.graphics.shaders.Grayscale;
import funkin.graphics.shaders.GaussianBlurShader;
import openfl.display.BlendMode;
import funkin.graphics.FunkinSprite;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.addons.effects.FlxTrail;
import flixel.util.FlxColor;
class SongMenuItem extends FlxSpriteGroup class SongMenuItem extends FlxSpriteGroup
{ {
@ -31,9 +38,10 @@ class SongMenuItem extends FlxSpriteGroup
public var songText:CapsuleText; public var songText:CapsuleText;
public var favIcon:FlxSprite; public var favIcon:FlxSprite;
public var ranking:FlxSprite; public var ranking:FreeplayRank;
public var blurredRanking:FreeplayRank;
var ranks:Array<String> = ["fail", "average", "great", "excellent", "perfect"]; var ranks:Array<String> = ["fail", "average", "great", "excellent", "perfect", "perfectsick"];
public var targetPos:FlxPoint = new FlxPoint(); public var targetPos:FlxPoint = new FlxPoint();
public var doLerp:Bool = false; public var doLerp:Bool = false;
@ -47,6 +55,22 @@ class SongMenuItem extends FlxSpriteGroup
public var hsvShader(default, set):HSVShader; public var hsvShader(default, set):HSVShader;
// var diffRatingSprite:FlxSprite; // var diffRatingSprite:FlxSprite;
public var bpmText:FlxSprite;
public var difficultyText:FlxSprite;
public var weekType:FlxSprite;
public var newText:FlxSprite;
// public var weekType:FlxSprite;
public var bigNumbers:Array<CapsuleNumber> = [];
public var smallNumbers:Array<CapsuleNumber> = [];
public var weekNumbers:Array<CapsuleNumber> = [];
var impactThing:FunkinSprite;
public var tempr:Int;
public function new(x:Float, y:Float) public function new(x:Float, y:Float)
{ {
@ -59,12 +83,64 @@ class SongMenuItem extends FlxSpriteGroup
// capsule.animation // capsule.animation
add(capsule); add(capsule);
bpmText = new FlxSprite(144, 87).loadGraphic(Paths.image('freeplay/freeplayCapsule/bpmtext'));
bpmText.setGraphicSize(Std.int(bpmText.width * 0.9));
add(bpmText);
difficultyText = new FlxSprite(414, 87).loadGraphic(Paths.image('freeplay/freeplayCapsule/difficultytext'));
difficultyText.setGraphicSize(Std.int(difficultyText.width * 0.9));
add(difficultyText);
weekType = new FlxSprite(291, 87);
weekType.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/weektypes');
weekType.animation.addByPrefix('WEEK', 'WEEK text instance 1', 24, false);
weekType.animation.addByPrefix('WEEKEND', 'WEEKEND text instance 1', 24, false);
weekType.setGraphicSize(Std.int(weekType.width * 0.9));
add(weekType);
newText = new FlxSprite(454, 9);
newText.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/new');
newText.animation.addByPrefix('newAnim', 'NEW notif', 24, true);
newText.animation.play('newAnim', true);
newText.setGraphicSize(Std.int(newText.width * 0.9));
newText.visible = false;
add(newText);
// var debugNumber2:CapsuleNumber = new CapsuleNumber(0, 0, true, 2);
// add(debugNumber2);
for (i in 0...2)
{
var bigNumber:CapsuleNumber = new CapsuleNumber(466 + (i * 30), 32, true, 0);
add(bigNumber);
bigNumbers.push(bigNumber);
}
for (i in 0...3)
{
var smallNumber:CapsuleNumber = new CapsuleNumber(185 + (i * 11), 88.5, false, 0);
add(smallNumber);
smallNumbers.push(smallNumber);
}
// doesn't get added, simply is here to help with visibility of things for the pop in! // doesn't get added, simply is here to help with visibility of things for the pop in!
grpHide = new FlxGroup(); grpHide = new FlxGroup();
var rank:String = FlxG.random.getObject(ranks); var rank:String = FlxG.random.getObject(ranks);
ranking = new FlxSprite(capsule.width * 0.84, 30); tempr = FlxG.random.int(0, 5);
ranking = new FreeplayRank(420, 41, tempr);
add(ranking);
blurredRanking = new FreeplayRank(ranking.x, ranking.y, tempr);
blurredRanking.shader = new GaussianBlurShader(1);
add(blurredRanking);
// ranking.loadGraphic(Paths.image('freeplay/ranks/' + rank)); // ranking.loadGraphic(Paths.image('freeplay/ranks/' + rank));
// ranking.scale.x = ranking.scale.y = realScaled; // ranking.scale.x = ranking.scale.y = realScaled;
// ranking.alpha = 0.75; // ranking.alpha = 0.75;
@ -73,11 +149,11 @@ class SongMenuItem extends FlxSpriteGroup
// add(ranking); // add(ranking);
// grpHide.add(ranking); // grpHide.add(ranking);
switch (rank) // switch (rank)
{ // {
case 'perfect': // case 'perfect':
ranking.x -= 10; // ranking.x -= 10;
} // }
grayscaleShader = new Grayscale(1); grayscaleShader = new Grayscale(1);
@ -93,7 +169,7 @@ class SongMenuItem extends FlxSpriteGroup
grpHide.add(songText); grpHide.add(songText);
// TODO: Use value from metadata instead of random. // TODO: Use value from metadata instead of random.
updateDifficultyRating(FlxG.random.int(0, 15)); updateDifficultyRating(FlxG.random.int(0, 20));
pixelIcon = new FlxSprite(160, 35); pixelIcon = new FlxSprite(160, 35);
@ -103,21 +179,216 @@ class SongMenuItem extends FlxSpriteGroup
add(pixelIcon); add(pixelIcon);
grpHide.add(pixelIcon); grpHide.add(pixelIcon);
favIcon = new FlxSprite(400, 40); favIcon = new FlxSprite(380, 40);
favIcon.frames = Paths.getSparrowAtlas('freeplay/favHeart'); favIcon.frames = Paths.getSparrowAtlas('freeplay/favHeart');
favIcon.animation.addByPrefix('fav', 'favorite heart', 24, false); favIcon.animation.addByPrefix('fav', 'favorite heart', 24, false);
favIcon.animation.play('fav'); favIcon.animation.play('fav');
favIcon.setGraphicSize(50, 50); favIcon.setGraphicSize(50, 50);
favIcon.visible = false; favIcon.visible = false;
favIcon.blend = BlendMode.ADD;
add(favIcon); add(favIcon);
// grpHide.add(favIcon);
var weekNumber:CapsuleNumber = new CapsuleNumber(355, 88.5, false, 0);
add(weekNumber);
weekNumbers.push(weekNumber);
setVisibleGrp(false); setVisibleGrp(false);
} }
// no way to grab weeks rn, so this needs to be done :/
// negative values mean weekends
function checkWeek(name:String):Void
{
// trace(name);
var weekNum:Int = 0;
switch (name)
{
case 'bopeebo' | 'fresh' | 'dadbattle':
weekNum = 1;
case 'spookeez' | 'south' | 'monster':
weekNum = 2;
case 'pico' | 'philly-nice' | 'blammed':
weekNum = 3;
case "satin-panties" | 'high' | 'milf':
weekNum = 4;
case "cocoa" | 'eggnog' | 'winter-horrorland':
weekNum = 5;
case 'senpai' | 'roses' | 'thorns':
weekNum = 6;
case 'ugh' | 'guns' | 'stress':
weekNum = 7;
case 'darnell' | 'lit-up' | '2hot' | 'blazin':
weekNum = -1;
default:
weekNum = 0;
}
weekNumbers[0].digit = Std.int(Math.abs(weekNum));
if (weekNum == 0)
{
weekType.visible = false;
weekNumbers[0].visible = false;
}
else
{
weekType.visible = true;
weekNumbers[0].visible = true;
}
if (weekNum > 0)
{
weekType.animation.play('WEEK', true);
}
else
{
weekType.animation.play('WEEKEND', true);
weekNumbers[0].offset.x -= 35;
}
}
// 255, 27 normal
// 220, 27 favourited
public function checkClip():Void
{
var clipSize:Int = 290;
var clipType:Int = 0;
if (ranking.visible == true) clipType += 1;
if (favIcon.visible == true) clipType += 1;
switch (clipType)
{
case 2:
clipSize = 220;
case 1:
clipSize = 255;
}
songText.clipWidth = clipSize;
}
function updateBPM(newBPM:Int):Void
{
trace(newBPM);
var shiftX:Float = 191;
var tempShift:Float = 0;
if (Math.floor(newBPM / 100) == 1)
{
shiftX = 186;
}
for (i in 0...smallNumbers.length)
{
smallNumbers[i].x = this.x + (shiftX + (i * 11));
switch (i)
{
case 0:
if (newBPM < 100)
{
smallNumbers[i].digit = 0;
}
else
{
smallNumbers[i].digit = Math.floor(newBPM / 100) % 10;
}
case 1:
if (newBPM < 10)
{
smallNumbers[i].digit = 0;
}
else
{
smallNumbers[i].digit = Math.floor(newBPM / 10) % 10;
if (Math.floor(newBPM / 10) % 10 == 1) tempShift = -4;
}
case 2:
smallNumbers[i].digit = newBPM % 10;
default:
trace('why the fuck is this being called');
}
smallNumbers[i].x += tempShift;
}
// diffRatingSprite.loadGraphic(Paths.image('freeplay/diffRatings/diff${ratingPadded}'));
// diffRatingSprite.visible = false;
}
var evilTrail:FlxTrail;
public function fadeAnim()
{
impactThing = new FunkinSprite(0, 0);
impactThing.frames = capsule.frames;
impactThing.frame = capsule.frame;
impactThing.updateHitbox();
// impactThing.x = capsule.x;
// impactThing.y = capsule.y;
// picoFade.stamp(this, 0, 0);
impactThing.alpha = 0;
impactThing.zIndex = capsule.zIndex - 3;
add(impactThing);
FlxTween.tween(impactThing.scale, {x: 2.5, y: 2.5}, 0.5);
// FlxTween.tween(impactThing, {alpha: 0}, 0.5);
evilTrail = new FlxTrail(impactThing, null, 15, 2, 0.01, 0.069);
evilTrail.blend = BlendMode.ADD;
evilTrail.zIndex = capsule.zIndex - 5;
FlxTween.tween(evilTrail, {alpha: 0}, 0.6,
{
ease: FlxEase.quadOut,
onComplete: function(_) {
remove(evilTrail);
}
});
add(evilTrail);
switch (tempr)
{
case 0:
evilTrail.color = 0xFF6044FF;
case 1:
evilTrail.color = 0xFFEF8764;
case 2:
evilTrail.color = 0xFFEAF6FF;
case 3:
evilTrail.color = 0xFFFDCB42;
case 4:
evilTrail.color = 0xFFFF58B4;
case 5:
evilTrail.color = 0xFFFFB619;
}
}
public function getTrailColor():FlxColor
{
return evilTrail.color;
}
function updateDifficultyRating(newRating:Int):Void function updateDifficultyRating(newRating:Int):Void
{ {
var ratingPadded:String = newRating < 10 ? '0$newRating' : '$newRating'; var ratingPadded:String = newRating < 10 ? '0$newRating' : '$newRating';
for (i in 0...bigNumbers.length)
{
switch (i)
{
case 0:
if (newRating > 10)
{
bigNumbers[i].digit = 0;
}
else
{
bigNumbers[i].digit = Math.floor(newRating / 10);
}
case 1:
bigNumbers[i].digit = newRating % 10;
default:
trace('why the fuck is this being called');
}
}
// diffRatingSprite.loadGraphic(Paths.image('freeplay/diffRatings/diff${ratingPadded}')); // diffRatingSprite.loadGraphic(Paths.image('freeplay/diffRatings/diff${ratingPadded}'));
// diffRatingSprite.visible = false; // diffRatingSprite.visible = false;
} }
@ -168,9 +439,12 @@ class SongMenuItem extends FlxSpriteGroup
songText.text = songData?.songName ?? 'Random'; songText.text = songData?.songName ?? 'Random';
// Update capsule character. // Update capsule character.
if (songData?.songCharacter != null) setCharacter(songData.songCharacter); if (songData?.songCharacter != null) setCharacter(songData.songCharacter);
updateDifficultyRating(songData?.songRating ?? 0); updateBPM(Std.int(songData?.songStartingBpm) ?? 0);
updateDifficultyRating(songData?.difficultyRating ?? 0);
// Update opacity, offsets, etc. // Update opacity, offsets, etc.
updateSelected(); updateSelected();
checkWeek(songData?.songId);
} }
/** /**
@ -289,6 +563,28 @@ class SongMenuItem extends FlxSpriteGroup
override function update(elapsed:Float):Void override function update(elapsed:Float):Void
{ {
if (impactThing != null) impactThing.angle = capsule.angle;
// if (FlxG.keys.justPressed.I)
// {
// newText.y -= 1;
// trace(this.x - newText.x, this.y - newText.y);
// }
// if (FlxG.keys.justPressed.J)
// {
// newText.x -= 1;
// trace(this.x - newText.x, this.y - newText.y);
// }
// if (FlxG.keys.justPressed.L)
// {
// newText.x += 1;
// trace(this.x - newText.x, this.y - newText.y);
// }
// if (FlxG.keys.justPressed.K)
// {
// newText.y += 1;
// trace(this.x - newText.x, this.y - newText.y);
// }
if (doJumpIn) if (doJumpIn)
{ {
frameInTicker += elapsed; frameInTicker += elapsed;
@ -358,5 +654,137 @@ class SongMenuItem extends FlxSpriteGroup
capsule.animation.play(this.selected ? "selected" : "unselected"); capsule.animation.play(this.selected ? "selected" : "unselected");
ranking.alpha = this.selected ? 1 : 0.7; ranking.alpha = this.selected ? 1 : 0.7;
ranking.color = this.selected ? 0xFFFFFFFF : 0xFFAAAAAA; ranking.color = this.selected ? 0xFFFFFFFF : 0xFFAAAAAA;
if (selected)
{
if (songText.tooLong == true) songText.initMove();
}
else
{
if (songText.tooLong == true) songText.resetText();
}
}
}
class FreeplayRank extends FlxSprite
{
public var rank(default, set):Int = 0;
var numToRank:Array<String> = ["LOSS", "GOOD", "GREAT", "EXCELLENT", "PERFECT", "PERFECTSICK"];
function set_rank(val):Int
{
animation.play(numToRank[val], true, false);
centerOffsets(false);
switch (val)
{
case 0:
// offset.x -= 1;
case 1:
// offset.x -= 1;
offset.y -= 8;
case 2:
// offset.x -= 1;
offset.y -= 8;
case 3:
// offset.y += 5;
case 4:
// offset.y += 5;
default:
centerOffsets(false);
}
updateHitbox();
return val;
}
public var baseY:Float = 0;
public var baseX:Float = 0;
public function new(x:Float, y:Float, ?initRank:Int = 0)
{
super(x, y);
frames = Paths.getSparrowAtlas('freeplay/rankbadges');
animation.addByPrefix('PERFECT', 'PERFECT rank0', 24, false);
animation.addByPrefix('EXCELLENT', 'EXCELLENT rank0', 24, false);
animation.addByPrefix('GOOD', 'GOOD rank0', 24, false);
animation.addByPrefix('PERFECTSICK', 'PERFECT rank GOLD', 24, false);
animation.addByPrefix('GREAT', 'GREAT rank0', 24, false);
animation.addByPrefix('LOSS', 'LOSS rank0', 24, false);
blend = BlendMode.ADD;
this.rank = initRank;
animation.play(numToRank[initRank], true);
// setGraphicSize(Std.int(width * 0.9));
scale.set(0.9, 0.9);
updateHitbox();
}
}
class CapsuleNumber extends FlxSprite
{
public var digit(default, set):Int = 0;
function set_digit(val):Int
{
animation.play(numToString[val], true, false, 0);
centerOffsets(false);
switch (val)
{
case 1:
offset.x -= 4;
case 3:
offset.x -= 1;
case 6:
case 4:
// offset.y += 5;
case 9:
// offset.y += 5;
default:
centerOffsets(false);
}
return val;
}
public var baseY:Float = 0;
public var baseX:Float = 0;
var numToString:Array<String> = ["ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"];
public function new(x:Float, y:Float, big:Bool = false, ?initDigit:Int = 0)
{
super(x, y);
if (big)
{
frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/bignumbers');
}
else
{
frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/smallnumbers');
}
for (i in 0...10)
{
var stringNum:String = numToString[i];
animation.addByPrefix(stringNum, '$stringNum', 24, false);
}
this.digit = initDigit;
animation.play(numToString[initDigit], true);
setGraphicSize(Std.int(width * 0.9));
updateHitbox();
} }
} }

View file

@ -351,8 +351,7 @@ class MainMenuState extends MusicBeatState
maxCombo: 0, maxCombo: 0,
totalNotesHit: 0, totalNotesHit: 0,
totalNotes: 0, totalNotes: 0,
}, }
accuracy: 0,
}); });
} }
#end #end

View file

@ -13,11 +13,10 @@ class LevelProp extends Bopper
// Only reset the prop if the asset path has changed. // Only reset the prop if the asset path has changed.
if (propData == null || value?.assetPath != propData?.assetPath) if (propData == null || value?.assetPath != propData?.assetPath)
{ {
this.visible = (value != null);
this.propData = value;
danceEvery = this.propData?.danceEvery ?? 0;
applyData(); applyData();
} }
this.visible = (value != null);
danceEvery = this.propData?.danceEvery ?? 0;
return this.propData; return this.propData;
} }

View file

@ -57,8 +57,7 @@ class LoadingState extends MusicBeatSubState
funkay.scrollFactor.set(); funkay.scrollFactor.set();
funkay.screenCenter(); funkay.screenCenter();
loadBar = new FunkinSprite(0, FlxG.height - 20).makeSolidColor(FlxG.width, 10, 0xFFff16d2); loadBar = new FunkinSprite(0, FlxG.height - 20).makeSolidColor(0, 10, 0xFFff16d2);
loadBar.screenCenter(X);
add(loadBar); add(loadBar);
initSongsManifest().onComplete(function(lib) { initSongsManifest().onComplete(function(lib) {
@ -163,8 +162,15 @@ class LoadingState extends MusicBeatSubState
targetShit = FlxMath.remapToRange(callbacks.numRemaining / callbacks.length, 1, 0, 0, 1); targetShit = FlxMath.remapToRange(callbacks.numRemaining / callbacks.length, 1, 0, 0, 1);
var lerpWidth:Int = Std.int(FlxMath.lerp(loadBar.width, FlxG.width * targetShit, 0.2)); var lerpWidth:Int = Std.int(FlxMath.lerp(loadBar.width, FlxG.width * targetShit, 0.2));
// this if-check prevents the setGraphicSize function
// from setting the width of the loadBar to the height of the loadBar
// this is a behaviour that is implemented in the setGraphicSize function
// if the width parameter is equal to 0
if (lerpWidth > 0)
{
loadBar.setGraphicSize(lerpWidth, loadBar.height); loadBar.setGraphicSize(lerpWidth, loadBar.height);
loadBar.updateHitbox(); loadBar.updateHitbox();
}
FlxG.watch.addQuick('percentage?', callbacks.numRemaining / callbacks.length); FlxG.watch.addQuick('percentage?', callbacks.numRemaining / callbacks.length);
} }

View file

@ -455,6 +455,17 @@ class Constants
public static final JUDGEMENT_BAD_COMBO_BREAK:Bool = true; public static final JUDGEMENT_BAD_COMBO_BREAK:Bool = true;
public static final JUDGEMENT_SHIT_COMBO_BREAK:Bool = true; public static final JUDGEMENT_SHIT_COMBO_BREAK:Bool = true;
// % Sick
public static final RANK_PERFECT_PLAT_THRESHOLD:Float = 1.0; // % Sick
public static final RANK_PERFECT_GOLD_THRESHOLD:Float = 0.85; // % Sick
// % Hit
public static final RANK_PERFECT_THRESHOLD:Float = 1.00;
public static final RANK_EXCELLENT_THRESHOLD:Float = 0.90;
public static final RANK_GREAT_THRESHOLD:Float = 0.75;
public static final RANK_GOOD_THRESHOLD:Float = 0.60;
// public static final RANK_SHIT_THRESHOLD:Float = 0.00;
/** /**
* FILE EXTENSIONS * FILE EXTENSIONS
*/ */

View file

@ -1,136 +0,0 @@
package funkin.util;
import funkin.util.tools.MapTools;
import haxe.DynamicAccess;
/**
* Utilities for working with anonymous structures.
*/
class StructureUtil
{
/**
* Merge two structures, with the second overwriting the first.
* Performs a SHALLOW clone, where child structures are not merged.
* @param a The base structure.
* @param b The new structure.
* @return The merged structure.
*/
public static function merge(a:Dynamic, b:Dynamic):Dynamic
{
var result:DynamicAccess<Dynamic> = Reflect.copy(a);
for (field in Reflect.fields(b))
{
result.set(field, Reflect.field(b, field));
}
return result;
}
public static function toMap(a:Dynamic):haxe.ds.Map<String, Dynamic>
{
var result:haxe.ds.Map<String, Dynamic> = [];
for (field in Reflect.fields(a))
{
result.set(field, Reflect.field(a, field));
}
return result;
}
public static function isMap(a:Dynamic):Bool
{
return Std.isOfType(a, haxe.Constraints.IMap);
}
public static function isObject(a:Dynamic):Bool
{
switch (Type.typeof(a))
{
case TObject:
return true;
default:
return false;
}
}
public static function isPrimitive(a:Dynamic):Bool
{
switch (Type.typeof(a))
{
case TInt | TFloat | TBool:
return true;
case TClass(c):
return false;
case TEnum(e):
return false;
case TObject:
return false;
case TFunction:
return false;
case TNull:
return true;
case TUnknown:
return false;
default:
return false;
}
}
/**
* Merge two structures, with the second overwriting the first.
* Performs a DEEP clone, where child structures are also merged recursively.
* @param a The base structure.
* @param b The new structure.
* @return The merged structure.
*/
public static function deepMerge(a:Dynamic, b:Dynamic):Dynamic
{
if (a == null) return b;
if (b == null) return null;
if (isPrimitive(a) && isPrimitive(b)) return b;
if (isMap(b))
{
if (isMap(a))
{
return MapTools.merge(a, b);
}
else
{
return StructureUtil.toMap(a).merge(b);
}
}
if (!Reflect.isObject(a) || !Reflect.isObject(b)) return b;
if (Std.isOfType(b, haxe.ds.StringMap))
{
if (Std.isOfType(a, haxe.ds.StringMap))
{
return MapTools.merge(a, b);
}
else
{
return StructureUtil.toMap(a).merge(b);
}
}
var result:DynamicAccess<Dynamic> = Reflect.copy(a);
for (field in Reflect.fields(b))
{
if (Reflect.isObject(b))
{
// Note that isObject also returns true for class instances,
// but we just assume that's not a problem here.
result.set(field, deepMerge(Reflect.field(result, field), Reflect.field(b, field)));
}
else
{
// If we're here, b[field] is a primitive.
result.set(field, Reflect.field(b, field));
}
}
return result;
}
}

View file

@ -32,6 +32,25 @@ class VersionUtil
} }
} }
public static function repairVersion(version:thx.semver.Version):thx.semver.Version
{
var versionData:thx.semver.Version.SemVer = version;
if (thx.Types.isAnonymousObject(versionData.version))
{
// This is bad! versionData.version should be an array!
versionData.version = [versionData.version[0], versionData.version[1], versionData.version[2]];
var fixedVersion:thx.semver.Version = versionData;
return fixedVersion;
}
else
{
// No need for repair.
return version;
}
}
/** /**
* Checks that a given verison number satisisfies a given version rule. * Checks that a given verison number satisisfies a given version rule.
* Version rule can be complex, e.g. "1.0.x" or ">=1.0.0,<1.1.0", or anything NPM supports. * Version rule can be complex, e.g. "1.0.x" or ">=1.0.0,<1.1.0", or anything NPM supports.

View file

@ -23,7 +23,7 @@ class InlineMacro
var fields:Array<haxe.macro.Expr.Field> = haxe.macro.Context.getBuildFields(); var fields:Array<haxe.macro.Expr.Field> = haxe.macro.Context.getBuildFields();
// Find the field with the given name. // Find the field with the given name.
var targetField:Null<haxe.macro.Expr.Field> = fields.find(function(f) return f.name == field var targetField:Null<haxe.macro.Expr.Field> = thx.Arrays.find(fields, function(f) return f.name == field
&& (MacroUtil.isFieldStatic(f) == isStatic)); && (MacroUtil.isFieldStatic(f) == isStatic));
// If the field was not found, throw an error. // If the field was not found, throw an error.

View file

@ -5,72 +5,6 @@ package funkin.util.tools;
*/ */
class ArrayTools class ArrayTools
{ {
/**
* Returns a copy of the array with all duplicate elements removed.
* @param array The array to remove duplicates from.
* @return A copy of the array with all duplicate elements removed.
*/
public static function unique<T>(array:Array<T>):Array<T>
{
var result:Array<T> = [];
for (element in array)
{
if (!result.contains(element))
{
result.push(element);
}
}
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.
* @param input The array to search
* @param predicate The predicate to call
* @return The result
*/
public static function find<T>(input:Array<T>, predicate:T->Bool):Null<T>
{
for (element in input)
{
if (predicate(element)) return element;
}
return null;
}
/**
* Return the index of the first element of the array that satisfies the predicate, or `-1` if none do.
* @param input The array to search
* @param predicate The predicate to call
* @return The index of the result
*/
public static function findIndex<T>(input:Array<T>, predicate:T->Bool):Int
{
for (index in 0...input.length)
{
if (predicate(input[index])) return index;
}
return -1;
}
/* /*
* Push an element to the array if it is not already present. * Push an element to the array if it is not already present.
* @param input The array to push to * @param input The array to push to

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="arrows.png">
<SubTexture name="staticLeft0001" x="0" y="0" width="17" height="17" />
<SubTexture name="staticDown0001" x="17" y="0" width="17" height="17" />
<SubTexture name="staticUp0001" x="34" y="0" width="17" height="17" />
<SubTexture name="staticRight0001" x="51" y="0" width="17" height="17" />
<SubTexture name="noteLeft0001" x="0" y="17" width="17" height="17" />
<SubTexture name="noteDown0001" x="17" y="17" width="17" height="17" />
<SubTexture name="noteUp0001" x="34" y="17" width="17" height="17" />
<SubTexture name="noteRight0001" x="51" y="17" width="17" height="17" />
<SubTexture name="pressedLeft0001" x="0" y="17" width="17" height="17" />
<SubTexture name="pressedDown0001" x="17" y="17" width="17" height="17" />
<SubTexture name="pressedUp0001" x="34" y="17" width="17" height="17" />
<SubTexture name="pressedRight0001" x="51" y="17" width="17" height="17" />
<SubTexture name="pressedLeft0002" x="0" y="34" width="17" height="17" />
<SubTexture name="pressedDown0002" x="17" y="34" width="17" height="17" />
<SubTexture name="pressedUp0002" x="34" y="34" width="17" height="17" />
<SubTexture name="pressedRight0002" x="51" y="34" width="17" height="17" />
<SubTexture name="confirmLeft0001" x="0" y="51" width="17" height="17" />
<SubTexture name="confirmDown0001" x="17" y="51" width="17" height="17" />
<SubTexture name="confirmUp0001" x="34" y="51" width="17" height="17" />
<SubTexture name="confirmRight0001" x="51" y="51" width="17" height="17" />
<SubTexture name="confirmLeft0002" x="0" y="68" width="17" height="17" />
<SubTexture name="confirmDown0002" x="17" y="68" width="17" height="17" />
<SubTexture name="confirmUp0002" x="34" y="68" width="17" height="17" />
<SubTexture name="confirmRight0002" x="51" y="68" width="17" height="17" />
</TextureAtlas>