Merge branch 'freeplay-sort'

This commit is contained in:
Cameron Taylor 2022-12-14 13:55:01 -05:00
commit 0b24dd537e
4 changed files with 435 additions and 164 deletions

212
hmm.json
View File

@ -1,112 +1,104 @@
{
"dependencies": [
{
"name": "discord_rpc",
"type": "git",
"dir": null,
"ref": "2d83fa8",
"url": "https://github.com/Aidan63/linc_discord-rpc"
},
{
"name": "flixel",
"type": "git",
"dir": null,
"ref": "dev",
"url": "https://github.com/MasterEric/flixel"
},
{
"name": "flixel-addons",
"type": "git",
"dir": null,
"ref": "a3877f0",
"url": "https://github.com/MasterEric/flixel-addons"
},
{
"name": "flixel-addons",
"type": "git",
"dir": null,
"ref": "dev",
"url": "https://github.com/MasterEric/flixel-addons"
},
{
"name": "flixel-ui",
"type": "haxelib",
"version": "2.4.0"
},
{
"name": "flxanimate",
"type": "git",
"dir": null,
"ref": "18b2060",
"url": "https://github.com/Dot-Stuff/flxanimate"
},
{
"name": "format",
"type": "haxelib",
"version": null
},
{
"name": "haxeui-core",
"type": "git",
"dir": null,
"ref": "fc8d656b",
"url": "https://github.com/haxeui/haxeui-core/"
},
{
"name": "haxeui-flixel",
"type": "git",
"dir": null,
"ref": "80941a7",
"url": "https://github.com/haxeui/haxeui-flixel"
},
{
"name": "hmm",
"type": "haxelib",
"version": "2.1.0"
},
{
"name": "hscript",
"type": "haxelib",
"version": "2.5.0"
},
{
"name": "hxcpp",
"type": "haxelib",
"version": "4.2.1"
},
{
"name": "hxcpp-debug-server",
"type": "haxelib",
"version": "1.2.4"
},
{
"name": "hxp",
"type": "haxelib",
"version": null
},
{
"name": "lime",
"type": "haxelib",
"version": null
},
{
"name": "openfl",
"type": "git",
"dir": null,
"ref": "develop",
"url": "https://github.com/openfl/openfl"
},
{
"name": "polymod",
"type": "git",
"dir": null,
"ref": "develop",
"url": "https://github.com/larsiusprime/polymod"
},
{
"name": "thx.semver",
"type": "haxelib",
"version": "0.2.2"
}
]
"dependencies": [{
"name": "discord_rpc",
"type": "git",
"dir": null,
"ref": "2d83fa8",
"url": "https://github.com/Aidan63/linc_discord-rpc"
},
{
"name": "flixel",
"type": "git",
"dir": null,
"ref": "a629f9a5",
"url": "https://github.com/MasterEric/flixel"
},
{
"name": "flixel-addons",
"type": "git",
"dir": null,
"ref": "752c3d7",
"url": "https://github.com/MasterEric/flixel-addons"
},
{
"name": "flixel-ui",
"type": "haxelib",
"version": "2.4.0"
},
{
"name": "flxanimate",
"type": "git",
"dir": null,
"ref": "18b2060",
"url": "https://github.com/Dot-Stuff/flxanimate"
},
{
"name": "format",
"type": "haxelib",
"version": "3.5.0"
},
{
"name": "haxeui-core",
"type": "git",
"dir": null,
"ref": "fc8d656b",
"url": "https://github.com/haxeui/haxeui-core/"
},
{
"name": "haxeui-flixel",
"type": "git",
"dir": null,
"ref": "80941a7",
"url": "https://github.com/haxeui/haxeui-flixel"
},
{
"name": "hmm",
"type": "haxelib",
"version": "2.1.0"
},
{
"name": "hscript",
"type": "haxelib",
"version": "2.5.0"
},
{
"name": "hxcpp",
"type": "haxelib",
"version": "4.2.1"
},
{
"name": "hxcpp-debug-server",
"type": "haxelib",
"version": "1.2.4"
},
{
"name": "hxp",
"type": "haxelib",
"version": "1.2.2"
},
{
"name": "lime",
"type": "haxelib",
"version": "8.0.0"
},
{
"name": "openfl",
"type": "git",
"dir": null,
"ref": "3fd5763c1",
"url": "https://github.com/MasterEric/openfl"
},
{
"name": "polymod",
"type": "git",
"dir": null,
"ref": "547c8ee",
"url": "https://github.com/larsiusprime/polymod"
},
{
"name": "thx.semver",
"type": "haxelib",
"version": "0.2.2"
}
]
}

View File

@ -7,6 +7,7 @@ import flixel.FlxSprite;
import flixel.FlxState;
import flixel.addons.display.FlxGridOverlay;
import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.ui.FlxInputText;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup;
import flixel.group.FlxSpriteGroup;
@ -24,6 +25,7 @@ import funkin.Controls.Control;
import funkin.freeplayStuff.BGScrollingText;
import funkin.freeplayStuff.DJBoyfriend;
import funkin.freeplayStuff.FreeplayScore;
import funkin.freeplayStuff.LetterSort;
import funkin.freeplayStuff.SongMenuItem;
import funkin.play.HealthIcon;
import funkin.play.PlayState;
@ -69,6 +71,8 @@ class FreeplayState extends MusicBeatSubstate
private var iconArray:Array<HealthIcon> = [];
var typing:FlxInputText;
override function create()
{
FlxTransitionableState.skipNextTransIn = true;
@ -240,6 +244,22 @@ class FreeplayState extends MusicBeatSubstate
add(new DifficultySelector(20, grpDifficulties.y - 10, false, controls));
add(new DifficultySelector(325, grpDifficulties.y - 10, true, controls));
var letterSort:LetterSort = new LetterSort(300, 100);
add(letterSort);
letterSort.changeSelectionCallback = (str) ->
{
switch (str)
{
case "fav":
generateSongList({filterType: FAVORITE}, true);
case "ALL":
generateSongList(null, true);
default:
generateSongList({filterType: STARTSWITH, filterData: str}, true);
}
};
new FlxTimer().start(1 / 24, function(handShit)
{
fnfFreeplay.visible = true;
@ -261,55 +281,7 @@ class FreeplayState extends MusicBeatSubstate
grpTxtScrolls.visible = true;
});
for (i in 0...songs.length)
{
var funnyMenu:SongMenuItem = new SongMenuItem(FlxG.width, (i * 150) + 160, songs[i].songName);
funnyMenu.targetPos.x = funnyMenu.x;
funnyMenu.ID = i;
funnyMenu.alpha = 0.5;
funnyMenu.songText.visible = false;
fp.updateScore(0);
new FlxTimer().start((1 / 24) * i, function(doShit)
{
funnyMenu.doJumpIn = true;
});
new FlxTimer().start((0.09 * i) + 0.85, function(lerpTmr)
{
funnyMenu.doLerp = true;
});
new FlxTimer().start(((0.20 * i) / (1 + i)) + 0.75, function(swagShi)
{
funnyMenu.songText.visible = true;
funnyMenu.alpha = 1;
});
grpCapsules.add(funnyMenu);
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i].songName, true, false);
songText.x += 100;
songText.isMenuItem = true;
songText.targetY = i;
// grpSongs.add(songText);
var icon:HealthIcon = new HealthIcon(songs[i].songCharacter);
// icon.sprTracker = songText;
// using a FlxGroup is too much fuss!
iconArray.push(icon);
// add(icon);
// songText.x += 40;
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
// songText.screenCenter(X);
}
changeSelection();
changeDiff();
generateSongList();
// FlxG.sound.playMusic(Paths.music('title'), 0);
// FlxG.sound.music.fadeIn(2, 0, 0.8);
@ -340,6 +312,15 @@ class FreeplayState extends MusicBeatSubstate
funnyCam.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(funnyCam);
typing = new FlxInputText(100, 100);
add(typing);
typing.callback = function(txt, action)
{
// generateSongList(new EReg(txt.trim(), "ig"));
trace(action);
};
forEach(function(bs)
{
bs.cameras = [funnyCam];
@ -348,6 +329,112 @@ class FreeplayState extends MusicBeatSubstate
super.create();
}
public function generateSongList(?filterStuff:SongFilter, ?force:Bool = false)
{
curSelected = 0;
grpCapsules.clear();
// var regexp:EReg = regexp;
var tempSongs:Array<SongMetadata> = songs;
if (filterStuff != null)
{
switch (filterStuff.filterType)
{
case STARTSWITH:
tempSongs = tempSongs.filter(str ->
{
return str.songName.toLowerCase().startsWith(filterStuff.filterData);
});
case ALL:
// no filter!
case FAVORITE:
tempSongs = tempSongs.filter(str ->
{
return str.isFav;
});
default:
// return all on default
}
}
// if (regexp != null)
// tempSongs = songs.filter(item -> regexp.match(item.songName));
// tempSongs.sort(function(a, b):Int
// {
// var tempA = a.songName.toUpperCase();
// var tempB = b.songName.toUpperCase();
// if (tempA < tempB)
// return -1;
// else if (tempA > tempB)
// return 1;
// else
// return 0;
// });
for (i in 0...tempSongs.length)
{
var funnyMenu:SongMenuItem = new SongMenuItem(FlxG.width, (i * 150) + 160, tempSongs[i].songName);
funnyMenu.targetPos.x = funnyMenu.x;
funnyMenu.ID = i;
funnyMenu.alpha = 0.5;
funnyMenu.songText.visible = false;
funnyMenu.favIcon.visible = tempSongs[i].isFav;
fp.updateScore(0);
new FlxTimer().start((1 / 24) * i, function(doShit)
{
funnyMenu.doJumpIn = true;
});
new FlxTimer().start((0.09 * i) + 0.85, function(lerpTmr)
{
funnyMenu.doLerp = true;
});
if (!force)
{
new FlxTimer().start(((0.20 * i) / (1 + i)) + 0.75, function(swagShi)
{
funnyMenu.songText.visible = true;
funnyMenu.alpha = 1;
});
}
else
{
funnyMenu.songText.visible = true;
funnyMenu.alpha = 1;
}
grpCapsules.add(funnyMenu);
var songText:Alphabet = new Alphabet(0, (70 * i) + 30, tempSongs[i].songName, true, false);
songText.x += 100;
songText.isMenuItem = true;
songText.targetY = i;
// grpSongs.add(songText);
var icon:HealthIcon = new HealthIcon(tempSongs[i].songCharacter);
// icon.sprTracker = songText;
// using a FlxGroup is too much fuss!
iconArray.push(icon);
// add(icon);
// songText.x += 40;
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
// songText.screenCenter(X);
}
changeSelection();
changeDiff();
}
public function addSong(songName:String, weekNum:Int, songCharacter:String)
{
songs.push(new SongMetadata(songName, weekNum, songCharacter));
@ -379,10 +466,46 @@ class FreeplayState extends MusicBeatSubstate
var initTouchPos:FlxPoint = new FlxPoint();
var spamTimer:Float = 0;
var spamming:Bool = false;
override function update(elapsed:Float)
{
super.update(elapsed);
if (FlxG.keys.justPressed.F)
{
var realShit = curSelected;
songs[curSelected].isFav = !songs[curSelected].isFav;
if (songs[curSelected].isFav)
{
FlxTween.tween(grpCapsules.members[realShit], {angle: 360}, 0.4, {
ease: FlxEase.elasticOut,
onComplete: _ ->
{
grpCapsules.members[realShit].favIcon.visible = true;
grpCapsules.members[realShit].favIcon.animation.play("fav");
}
});
}
else
{
grpCapsules.members[realShit].favIcon.animation.play('fav', false, true);
new FlxTimer().start((1 / 24) * 14, _ ->
{
grpCapsules.members[realShit].favIcon.visible = false;
});
new FlxTimer().start((1 / 24) * 24, _ ->
{
FlxTween.tween(grpCapsules.members[realShit], {angle: 0}, 0.4, {ease: FlxEase.elasticOut});
});
}
}
if (FlxG.keys.justPressed.T)
typing.hasFocus = true;
if (FlxG.sound.music != null)
{
if (FlxG.sound.music.volume < 0.7)
@ -484,6 +607,31 @@ class FreeplayState extends MusicBeatSubstate
}
#end
if (controls.UI_UP || controls.UI_DOWN)
{
spamTimer += elapsed;
if (spamming)
{
if (spamTimer >= 0.07)
{
spamTimer = 0;
if (controls.UI_UP)
changeSelection(-1);
else
changeSelection(1);
}
}
else if (spamTimer >= 0.9)
spamming = true;
}
else
{
spamming = false;
spamTimer = 0;
}
if (upP)
{
dj.resetAFKTimer();
@ -512,7 +660,7 @@ class FreeplayState extends MusicBeatSubstate
changeDiff(1);
}
if (controls.BACK)
if (controls.BACK && !typing.hasFocus)
{
FlxG.sound.play(Paths.sound('cancelMenu'));
@ -644,8 +792,8 @@ class FreeplayState extends MusicBeatSubstate
curSelected += change;
if (curSelected < 0)
curSelected = songs.length - 1;
if (curSelected >= songs.length)
curSelected = grpCapsules.members.length - 1;
if (curSelected >= grpCapsules.members.length)
curSelected = 0;
// selector.y = (70 * curSelected) + 30;
@ -679,7 +827,8 @@ class FreeplayState extends MusicBeatSubstate
capsule.targetPos.y -= 100; // another 100 for good measure
}
grpCapsules.members[curSelected].selected = true;
if (grpCapsules.members.length > 0)
grpCapsules.members[curSelected].selected = true;
}
}
@ -729,16 +878,31 @@ class DifficultySelector extends FlxSprite
}
}
typedef SongFilter =
{
var filterType:FilterType;
var ?filterData:Dynamic;
}
enum abstract FilterType(String)
{
var STARTSWITH;
var FAVORITE;
var ALL;
}
class SongMetadata
{
public var songName:String = "";
public var week:Int = 0;
public var songCharacter:String = "";
public var isFav:Bool = false;
public function new(song:String, week:Int, songCharacter:String)
public function new(song:String, week:Int, songCharacter:String, ?isFav:Bool = false)
{
this.songName = song;
this.week = week;
this.songCharacter = songCharacter;
this.isFav = isFav;
}
}

View File

@ -0,0 +1,106 @@
package funkin.freeplayStuff;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
class LetterSort extends FlxTypedSpriteGroup<FreeplayLetter>
{
public var letters:Array<FreeplayLetter> = [];
var curSelection:Int = 0;
public var changeSelectionCallback:String->Void;
public function new(x, y)
{
super(x, y);
var leftArrow:FreeplayLetter = new FreeplayLetter(-20, 0);
leftArrow.animation.play("arrow");
add(leftArrow);
for (i in 0...6)
{
var letter:FreeplayLetter = new FreeplayLetter(i * 80, 0, i);
add(letter);
letters.push(letter);
if (i == 3)
letter.alpha = 0.6;
var sep:FreeplayLetter = new FreeplayLetter((i * 80) + 50, 0);
sep.animation.play("seperator");
add(sep);
}
// changeSelection(-3);
}
override function update(elapsed:Float)
{
super.update(elapsed);
if (FlxG.keys.justPressed.E)
changeSelection(1);
if (FlxG.keys.justPressed.Q)
changeSelection(-1);
}
public function changeSelection(diff:Int = 0)
{
for (letter in letters)
letter.changeLetter(diff);
if (changeSelectionCallback != null)
changeSelectionCallback(letters[3].arr[letters[3].curLetter]); // bullshit and long lol!
}
}
class FreeplayLetter extends FlxSprite
{
public var arr:Array<String> = [];
public var curLetter:Int = 0;
public function new(x:Float, y:Float, ?letterInd:Int)
{
super(x, y);
frames = Paths.getSparrowAtlas("freeplay/letterStuff");
var alphabet:String = "abcdefghijklmnopqrstuvwxyz";
arr = alphabet.split("");
arr.insert(0, "#");
arr.insert(0, "ALL");
arr.insert(0, "fav");
for (str in arr)
{
animation.addByPrefix(str, str + " "); // string followed by a space! intentional!
}
animation.addByPrefix("arrow", "mini arrow");
animation.addByPrefix("seperator", "seperator");
if (letterInd != null)
{
animation.play(arr[letterInd]);
curLetter = letterInd;
}
}
public function changeLetter(diff:Int = 0)
{
curLetter += diff;
if (curLetter < 0)
curLetter = arr.length - 1;
if (curLetter >= arr.length)
curLetter = 0;
animation.play(arr[curLetter]);
}
}

View File

@ -17,6 +17,7 @@ class SongMenuItem extends FlxSpriteGroup
public var songTitle:String = "Test";
public var songText:FlxText;
public var favIcon:FlxSprite;
public var targetPos:FlxPoint = new FlxPoint();
public var doLerp:Bool = false;
@ -40,6 +41,14 @@ class SongMenuItem extends FlxSpriteGroup
songText.color = 0xFF43C1EA;
add(songText);
favIcon = new FlxSprite(440, 40);
favIcon.frames = Paths.getSparrowAtlas('freeplay/favHeart');
favIcon.animation.addByPrefix('fav', "favorite heart", 24, false);
favIcon.animation.play('fav');
favIcon.antialiasing = true;
favIcon.setGraphicSize(60, 60);
add(favIcon);
selected = selected; // just to kickstart the set_selected
}