1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-26 23:16:46 +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

159
hmm.json
View file

@ -1,81 +1,82 @@
{ {
"dependencies": [{ "dependencies": [
"name": "discord_rpc", {
"type": "git", "name": "discord_rpc",
"dir": null, "type": "git",
"ref": "2d83fa8", "dir": null,
"url": "https://github.com/Aidan63/linc_discord-rpc" "ref": "2d83fa8",
}, "url": "https://github.com/Aidan63/linc_discord-rpc"
{ },
"name": "firetongue", {
"type": "git", "name": "firetongue",
"dir": null, "type": "git",
"ref": "c5666c8", "dir": null,
"url": "https://github.com/larsiusprime/firetongue" "ref": "c5666c8",
}, "url": "https://github.com/larsiusprime/firetongue"
{ },
"name": "flixel", {
"type": "git", "name": "flixel",
"dir": null, "type": "git",
"ref": "93a049d6", "dir": null,
"url": "https://github.com/haxeflixel/flixel" "ref": "93a049d6",
}, "url": "https://github.com/haxeflixel/flixel"
{ },
"name": "flixel-addons", {
"type": "haxelib", "name": "flixel-addons",
"version": "2.11.0" "type": "haxelib",
}, "version": "2.11.0"
{ },
"name": "flixel-ui", {
"type": "haxelib", "name": "flixel-ui",
"version": "2.4.0" "type": "haxelib",
}, "version": "2.4.0"
{ },
"name": "haxeui-core", {
"type": "haxelib", "name": "haxeui-core",
"version": null "type": "haxelib",
}, "version": "1.5.0"
{ },
"name": "haxeui-flixel", {
"type": "haxelib", "name": "haxeui-flixel",
"version": null "type": "haxelib",
}, "version": "1.5.0"
{ },
"name": "hscript", {
"type": "haxelib", "name": "hscript",
"version": "2.5.0" "type": "haxelib",
}, "version": "2.5.0"
{ },
"name": "hxcpp", {
"type": "haxelib", "name": "hxcpp",
"version": "4.2.1" "type": "haxelib",
}, "version": "4.2.1"
{ },
"name": "hxcpp-debug-server", {
"type": "haxelib", "name": "hxcpp-debug-server",
"version": "1.2.4" "type": "haxelib",
}, "version": "1.2.4"
{ },
"name": "lime", {
"type": "haxelib", "name": "lime",
"version": "7.9.0" "type": "haxelib",
}, "version": "7.9.0"
{ },
"name": "openfl", {
"type": "haxelib", "name": "openfl",
"version": "9.1.0" "type": "haxelib",
}, "version": "9.1.0"
{ },
"name": "polymod", {
"type": "git", "name": "polymod",
"dir": null, "type": "git",
"ref": "c858b48", "dir": null,
"url": "https://github.com/larsiusprime/polymod" "ref": "c858b48",
}, "url": "https://github.com/larsiusprime/polymod"
{ },
"name": "thx.semver", {
"type": "haxelib", "name": "thx.semver",
"version": "0.2.2" "type": "haxelib",
} "version": "0.2.2"
] }
]
} }

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'));