mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-16 03:43:36 +00:00
177280bd5b
very scuffed, OptionsMenu.hx is now mostly copied from FreeplayState.hx with no actual functionality currently it reads lines off of controls.txt and displays them on Options menu which is now accessible from main menu controls.txt has control functions prefixed with "set", IE "setUP", then the corresponding key on the following line IE "W"
213 lines
4.9 KiB
Haxe
213 lines
4.9 KiB
Haxe
package;
|
|
|
|
import flixel.FlxG;
|
|
import flixel.FlxObject;
|
|
import flixel.FlxSprite;
|
|
import flixel.effects.FlxFlicker;
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
import flixel.text.FlxText;
|
|
import flixel.tweens.FlxEase;
|
|
import flixel.tweens.FlxTween;
|
|
import flixel.util.FlxColor;
|
|
import io.newgrounds.NG;
|
|
import lime.app.Application;
|
|
|
|
using StringTools;
|
|
|
|
class MainMenuState extends MusicBeatState
|
|
{
|
|
var curSelected:Int = 0;
|
|
|
|
var menuItems:FlxTypedGroup<FlxSprite>;
|
|
|
|
#if !switch
|
|
var optionShit:Array<String> = ['story mode', 'freeplay', 'donate', 'options'];
|
|
#else
|
|
var optionShit:Array<String> = ['story mode', 'freeplay'];
|
|
#end
|
|
|
|
var magenta:FlxSprite;
|
|
var camFollow:FlxObject;
|
|
|
|
override function create()
|
|
{
|
|
if (!FlxG.sound.music.playing)
|
|
{
|
|
FlxG.sound.playMusic('assets/music/freakyMenu' + TitleState.soundExt);
|
|
}
|
|
|
|
persistentUpdate = persistentDraw = true;
|
|
|
|
var bg:FlxSprite = new FlxSprite(-80).loadGraphic('assets/images/menuBG.png');
|
|
bg.scrollFactor.x = 0;
|
|
bg.scrollFactor.y = 0.18;
|
|
bg.setGraphicSize(Std.int(bg.width * 1.1));
|
|
bg.updateHitbox();
|
|
bg.screenCenter();
|
|
bg.antialiasing = true;
|
|
add(bg);
|
|
|
|
camFollow = new FlxObject(0, 0, 1, 1);
|
|
add(camFollow);
|
|
|
|
magenta = new FlxSprite(-80).loadGraphic('assets/images/menuDesat.png');
|
|
magenta.scrollFactor.x = 0;
|
|
magenta.scrollFactor.y = 0.18;
|
|
magenta.setGraphicSize(Std.int(magenta.width * 1.1));
|
|
magenta.updateHitbox();
|
|
magenta.screenCenter();
|
|
magenta.visible = false;
|
|
magenta.antialiasing = true;
|
|
magenta.color = 0xFFfd719b;
|
|
add(magenta);
|
|
// magenta.scrollFactor.set();
|
|
|
|
menuItems = new FlxTypedGroup<FlxSprite>();
|
|
add(menuItems);
|
|
|
|
var tex = FlxAtlasFrames.fromSparrow('assets/images/FNF_main_menu_assets.png', 'assets/images/FNF_main_menu_assets.xml');
|
|
|
|
for (i in 0...optionShit.length)
|
|
{
|
|
var menuItem:FlxSprite = new FlxSprite(0, 60 + (i * 160));
|
|
menuItem.frames = tex;
|
|
menuItem.animation.addByPrefix('idle', optionShit[i] + " basic", 24);
|
|
menuItem.animation.addByPrefix('selected', optionShit[i] + " white", 24);
|
|
menuItem.animation.play('idle');
|
|
menuItem.ID = i;
|
|
menuItem.screenCenter(X);
|
|
menuItems.add(menuItem);
|
|
menuItem.scrollFactor.set();
|
|
menuItem.antialiasing = true;
|
|
}
|
|
|
|
FlxG.camera.follow(camFollow, null, 0.06);
|
|
|
|
var versionShit:FlxText = new FlxText(5, FlxG.height - 18, 0, "v" + Application.current.meta.get('version'), 12);
|
|
versionShit.scrollFactor.set();
|
|
versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
|
|
add(versionShit);
|
|
|
|
// NG.core.calls.event.logEvent('swag').send();
|
|
|
|
changeItem();
|
|
|
|
super.create();
|
|
}
|
|
|
|
var selectedSomethin:Bool = false;
|
|
|
|
override function update(elapsed:Float)
|
|
{
|
|
if (FlxG.sound.music.volume < 0.8)
|
|
{
|
|
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
|
|
}
|
|
|
|
if (!selectedSomethin)
|
|
{
|
|
if (controls.UP_P)
|
|
{
|
|
FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt);
|
|
changeItem(-1);
|
|
}
|
|
|
|
if (controls.DOWN_P)
|
|
{
|
|
FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt);
|
|
changeItem(1);
|
|
}
|
|
|
|
if (controls.BACK)
|
|
{
|
|
FlxG.switchState(new TitleState());
|
|
}
|
|
|
|
if (controls.ACCEPT)
|
|
{
|
|
if (optionShit[curSelected] == 'donate')
|
|
{
|
|
#if linux
|
|
Sys.command('/usr/bin/xdg-open', ["https://ninja-muffin24.itch.io/funkin", "&"]);
|
|
#else
|
|
FlxG.openURL('https://ninja-muffin24.itch.io/funkin');
|
|
#end
|
|
}
|
|
else
|
|
{
|
|
selectedSomethin = true;
|
|
FlxG.sound.play('assets/sounds/confirmMenu' + TitleState.soundExt);
|
|
|
|
FlxFlicker.flicker(magenta, 1.1, 0.15, false);
|
|
|
|
menuItems.forEach(function(spr:FlxSprite)
|
|
{
|
|
if (curSelected != spr.ID)
|
|
{
|
|
FlxTween.tween(spr, {alpha: 0}, 0.4, {
|
|
ease: FlxEase.quadOut,
|
|
onComplete: function(twn:FlxTween)
|
|
{
|
|
spr.kill();
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
FlxFlicker.flicker(spr, 1, 0.06, false, false, function(flick:FlxFlicker)
|
|
{
|
|
var daChoice:String = optionShit[curSelected];
|
|
|
|
switch (daChoice)
|
|
{
|
|
case 'story mode':
|
|
FlxG.switchState(new StoryMenuState());
|
|
trace("Story Menu Selected");
|
|
case 'freeplay':
|
|
FlxG.switchState(new FreeplayState());
|
|
|
|
trace("Freeplay Menu Selected");
|
|
|
|
case 'options':
|
|
FlxG.switchState(new OptionsMenu());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
super.update(elapsed);
|
|
|
|
menuItems.forEach(function(spr:FlxSprite)
|
|
{
|
|
spr.screenCenter(X);
|
|
});
|
|
}
|
|
|
|
function changeItem(huh:Int = 0)
|
|
{
|
|
curSelected += huh;
|
|
|
|
if (curSelected >= menuItems.length)
|
|
curSelected = 0;
|
|
if (curSelected < 0)
|
|
curSelected = menuItems.length - 1;
|
|
|
|
menuItems.forEach(function(spr:FlxSprite)
|
|
{
|
|
spr.animation.play('idle');
|
|
|
|
if (spr.ID == curSelected)
|
|
{
|
|
spr.animation.play('selected');
|
|
camFollow.setPosition(spr.getGraphicMidpoint().x, spr.getGraphicMidpoint().y);
|
|
}
|
|
|
|
spr.updateHitbox();
|
|
});
|
|
}
|
|
}
|