2022-09-27 08:37:42 +00:00
|
|
|
package funkin.freeplayStuff;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
import flixel.group.FlxGroup;
|
|
|
|
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
2023-08-06 20:24:34 +00:00
|
|
|
import flixel.tweens.FlxTween;
|
|
|
|
import flixel.tweens.FlxEase;
|
2023-08-06 21:02:37 +00:00
|
|
|
import flixel.util.FlxColor;
|
2023-08-07 02:20:18 +00:00
|
|
|
import flixel.util.FlxTimer;
|
|
|
|
import funkin.graphics.adobeanimate.FlxAtlasSprite;
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:54:55 +00:00
|
|
|
class LetterSort extends FlxTypedSpriteGroup<FlxSprite>
|
2022-09-27 08:37:42 +00:00
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
public var letters:Array<FreeplayLetter> = [];
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
var curSelection:Int = 0;
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
public var changeSelectionCallback:String->Void;
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:54:55 +00:00
|
|
|
var leftArrow:FlxSprite;
|
|
|
|
var rightArrow:FlxSprite;
|
2023-08-07 02:20:18 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
public function new(x, y)
|
|
|
|
{
|
|
|
|
super(x, y);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:54:55 +00:00
|
|
|
leftArrow = new FlxSprite(-20, 15).loadGraphic(Paths.image("freeplay/miniArrow"));
|
|
|
|
// leftArrow.animation.play("arrow");
|
2023-08-04 22:09:40 +00:00
|
|
|
leftArrow.flipX = true;
|
2023-01-23 03:25:45 +00:00
|
|
|
add(leftArrow);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-04 22:09:40 +00:00
|
|
|
for (i in 0...5)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
var letter:FreeplayLetter = new FreeplayLetter(i * 80, 0, i);
|
2023-08-07 16:33:12 +00:00
|
|
|
letter.x += 50;
|
|
|
|
letter.y += 50;
|
2023-08-06 20:24:34 +00:00
|
|
|
letter.ogY = y;
|
2023-01-23 03:25:45 +00:00
|
|
|
add(letter);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
letters.push(letter);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-06 21:06:07 +00:00
|
|
|
if (i != 2) letter.scale.x = letter.scale.y = 0.8;
|
|
|
|
else
|
2023-08-07 16:33:12 +00:00
|
|
|
{
|
|
|
|
// letter.x += 10;
|
|
|
|
// letter.scale.x = letter.scale.y = 1.1;
|
|
|
|
}
|
2023-08-06 21:02:37 +00:00
|
|
|
|
|
|
|
var darkness:Float = Math.abs(i - 2) / 6;
|
|
|
|
|
|
|
|
letter.color = letter.color.getDarkened(darkness);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-04 22:09:40 +00:00
|
|
|
// don't put the last seperator
|
|
|
|
if (i == 4) continue;
|
|
|
|
|
2023-08-07 02:54:55 +00:00
|
|
|
var sep:FlxSprite = new FlxSprite((i * 80) + 55, 20).loadGraphic(Paths.image("freeplay/seperator"));
|
|
|
|
// sep.animation.play("seperator");
|
2023-08-06 21:02:37 +00:00
|
|
|
sep.color = letter.color.getDarkened(darkness);
|
2023-01-23 03:25:45 +00:00
|
|
|
add(sep);
|
|
|
|
}
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:54:55 +00:00
|
|
|
rightArrow = new FlxSprite(380, 15).loadGraphic(Paths.image("freeplay/miniArrow"));
|
|
|
|
|
|
|
|
// rightArrow.animation.play("arrow");
|
2023-08-04 22:09:40 +00:00
|
|
|
add(rightArrow);
|
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
changeSelection(0);
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (FlxG.keys.justPressed.E) changeSelection(1);
|
|
|
|
if (FlxG.keys.justPressed.Q) changeSelection(-1);
|
|
|
|
}
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
public function changeSelection(diff:Int = 0)
|
|
|
|
{
|
2023-08-07 02:20:18 +00:00
|
|
|
if (diff < 0)
|
|
|
|
{
|
|
|
|
leftArrow.offset.x = 3;
|
|
|
|
new FlxTimer().start(2 / 24, function(_) {
|
|
|
|
leftArrow.offset.x = 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (diff > 0)
|
|
|
|
{
|
|
|
|
rightArrow.offset.x = -3;
|
|
|
|
new FlxTimer().start(2 / 24, function(_) {
|
|
|
|
rightArrow.offset.x = 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
curSelection += diff;
|
2023-08-07 16:33:12 +00:00
|
|
|
if (curSelection < 0) curSelection = letters[0].arr.length - 1;
|
|
|
|
if (curSelection >= letters[0].arr.length) curSelection = 0;
|
2023-08-06 20:24:34 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
for (letter in letters)
|
2023-08-07 16:33:12 +00:00
|
|
|
letter.changeLetter(diff, curSelection + 2);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-04 22:09:40 +00:00
|
|
|
if (changeSelectionCallback != null) changeSelectionCallback(letters[2].arr[letters[2].curLetter]); // bullshit and long lol!
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
2022-09-27 08:37:42 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 02:20:18 +00:00
|
|
|
class FreeplayLetter extends FlxAtlasSprite
|
2022-09-27 08:37:42 +00:00
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
public var arr:Array<String> = [];
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
public var curLetter:Int = 0;
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
public var ogY:Float = 0;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
public function new(x:Float, y:Float, ?letterInd:Int)
|
|
|
|
{
|
2023-08-07 02:20:18 +00:00
|
|
|
super(x, y, Paths.animateAtlas("freeplay/sortedLetters"));
|
|
|
|
// frames = Paths.getSparrowAtlas("freeplay/letterStuff");
|
|
|
|
// this.anim.play("AB");
|
|
|
|
// trace(this.anim.symbolDictionary);
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:20:18 +00:00
|
|
|
var alphabet:String = "AB-CD-EH-I L-MN-OR-s-t-UZ";
|
|
|
|
arr = alphabet.split("-");
|
2023-01-23 03:25:45 +00:00
|
|
|
arr.insert(0, "ALL");
|
|
|
|
arr.insert(0, "fav");
|
2023-08-07 02:20:18 +00:00
|
|
|
arr.insert(0, "#");
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:20:18 +00:00
|
|
|
// trace(arr);
|
|
|
|
|
|
|
|
// for (str in arr)
|
|
|
|
// {
|
|
|
|
// animation.addByPrefix(str, str + " "); // string followed by a space! intentional!
|
|
|
|
// }
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 02:20:18 +00:00
|
|
|
// animation.addByPrefix("arrow", "mini arrow");
|
|
|
|
// animation.addByPrefix("seperator", "seperator");
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (letterInd != null)
|
|
|
|
{
|
2023-08-07 16:33:12 +00:00
|
|
|
this.anim.play(arr[letterInd] + " move");
|
|
|
|
this.anim.pause();
|
2023-01-23 03:25:45 +00:00
|
|
|
curLetter = letterInd;
|
|
|
|
}
|
|
|
|
}
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-06 20:24:34 +00:00
|
|
|
public function changeLetter(diff:Int = 0, ?curSelection:Int)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
curLetter += diff;
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (curLetter < 0) curLetter = arr.length - 1;
|
|
|
|
if (curLetter >= arr.length) curLetter = 0;
|
2022-09-27 08:37:42 +00:00
|
|
|
|
2023-08-07 19:42:38 +00:00
|
|
|
var animName:String = arr[curLetter] + " move";
|
|
|
|
switch (arr[curLetter])
|
|
|
|
{
|
|
|
|
case "I L":
|
|
|
|
animName = "IL move";
|
|
|
|
case "s":
|
|
|
|
animName = "S move";
|
|
|
|
case "t":
|
|
|
|
animName = "T move";
|
|
|
|
}
|
|
|
|
|
|
|
|
this.anim.play(animName);
|
2023-08-07 16:33:12 +00:00
|
|
|
if (curSelection != curLetter) this.anim.pause();
|
|
|
|
updateHitbox();
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
2022-09-27 08:37:42 +00:00
|
|
|
}
|