1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-27 15:37:49 +00:00

basic sort and search

This commit is contained in:
Cameron Taylor 2022-09-26 18:22:45 -04:00
parent 182c7e3aa4
commit 09a037b20b
2 changed files with 172 additions and 129 deletions

View file

@ -1,5 +1,6 @@
{ {
"dependencies": [{ "dependencies": [
{
"name": "discord_rpc", "name": "discord_rpc",
"type": "git", "type": "git",
"dir": null, "dir": null,
@ -33,12 +34,12 @@
{ {
"name": "haxeui-core", "name": "haxeui-core",
"type": "haxelib", "type": "haxelib",
"version": null "version": "1.5.0"
}, },
{ {
"name": "haxeui-flixel", "name": "haxeui-flixel",
"type": "haxelib", "type": "haxelib",
"version": null "version": "1.5.0"
}, },
{ {
"name": "hscript", "name": "hscript",

View file

@ -7,6 +7,7 @@ import flixel.FlxSprite;
import flixel.FlxState; import flixel.FlxState;
import flixel.addons.display.FlxGridOverlay; import flixel.addons.display.FlxGridOverlay;
import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.ui.FlxInputText;
import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup; import flixel.group.FlxGroup;
import flixel.group.FlxSpriteGroup; import flixel.group.FlxSpriteGroup;
@ -66,6 +67,8 @@ class FreeplayState extends MusicBeatSubstate
private var iconArray:Array<HealthIcon> = []; private var iconArray:Array<HealthIcon> = [];
var typing:FlxInputText;
override function create() override function create()
{ {
FlxTransitionableState.skipNextTransIn = true; FlxTransitionableState.skipNextTransIn = true;
@ -260,55 +263,7 @@ class FreeplayState extends MusicBeatSubstate
grpTxtScrolls.visible = true; grpTxtScrolls.visible = true;
}); });
for (i in 0...songs.length) generateSongList();
{
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();
// FlxG.sound.playMusic(Paths.music('title'), 0); // FlxG.sound.playMusic(Paths.music('title'), 0);
// FlxG.sound.music.fadeIn(2, 0, 0.8); // FlxG.sound.music.fadeIn(2, 0, 0.8);
@ -339,6 +294,15 @@ class FreeplayState extends MusicBeatSubstate
funnyCam.bgColor = FlxColor.TRANSPARENT; funnyCam.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(funnyCam); 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) forEach(function(bs)
{ {
bs.cameras = [funnyCam]; bs.cameras = [funnyCam];
@ -347,6 +311,81 @@ class FreeplayState extends MusicBeatSubstate
super.create(); super.create();
} }
public function generateSongList(?regexp:EReg)
{
curSelected = 0;
grpCapsules.clear();
var regexp:EReg = regexp;
var tempSongs:Array<SongMetadata> = songs;
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;
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, 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) public function addSong(songName:String, weekNum:Int, songCharacter:String)
{ {
songs.push(new SongMetadata(songName, weekNum, songCharacter)); songs.push(new SongMetadata(songName, weekNum, songCharacter));
@ -382,6 +421,9 @@ class FreeplayState extends MusicBeatSubstate
{ {
super.update(elapsed); super.update(elapsed);
if (FlxG.keys.justPressed.T)
typing.hasFocus = true;
if (FlxG.sound.music != null) if (FlxG.sound.music != null)
{ {
if (FlxG.sound.music.volume < 0.7) if (FlxG.sound.music.volume < 0.7)
@ -496,7 +538,7 @@ class FreeplayState extends MusicBeatSubstate
if (controls.UI_RIGHT_P) if (controls.UI_RIGHT_P)
changeDiff(1); changeDiff(1);
if (controls.BACK) if (controls.BACK && !typing.hasFocus)
{ {
FlxG.sound.play(Paths.sound('cancelMenu')); FlxG.sound.play(Paths.sound('cancelMenu'));