1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-30 18:53:35 +00:00
Funkin/source/OptionsSubState.hx

80 lines
1.6 KiB
Haxe
Raw Normal View History

package;
2021-02-24 23:32:51 +00:00
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.text.FlxText;
import flixel.util.FlxColor;
class OptionsSubState extends MusicBeatSubstate
{
2021-02-24 23:32:51 +00:00
var textMenuItems:Array<String> = ['Master Volume', 'Sound Volume', 'Controls'];
var selector:FlxSprite;
var curSelected:Int = 0;
var grpOptionsTexts:FlxTypedGroup<FlxText>;
2021-03-13 18:37:59 +00:00
// public static var isDownscroll:Bool = false;
public function new()
{
super();
2021-02-24 23:32:51 +00:00
2021-03-10 00:41:03 +00:00
#if desktop
textMenuItems.push('Mods');
#end
2021-02-24 23:32:51 +00:00
grpOptionsTexts = new FlxTypedGroup<FlxText>();
add(grpOptionsTexts);
selector = new FlxSprite().makeGraphic(5, 5, FlxColor.RED);
add(selector);
for (i in 0...textMenuItems.length)
{
var optionText:FlxText = new FlxText(20, 20 + (i * 50), 0, textMenuItems[i], 32);
optionText.ID = i;
grpOptionsTexts.add(optionText);
}
}
override function update(elapsed:Float)
{
super.update(elapsed);
if (controls.UP_P)
curSelected -= 1;
if (controls.DOWN_P)
curSelected += 1;
if (curSelected < 0)
curSelected = textMenuItems.length - 1;
if (curSelected >= textMenuItems.length)
curSelected = 0;
grpOptionsTexts.forEach(function(txt:FlxText)
{
txt.color = FlxColor.WHITE;
if (txt.ID == curSelected)
txt.color = FlxColor.YELLOW;
});
if (controls.ACCEPT)
{
switch (textMenuItems[curSelected])
{
case "Controls":
FlxG.state.closeSubState();
FlxG.state.openSubState(new ControlsSubState());
2021-03-10 00:41:03 +00:00
case "Mods":
FlxG.state.closeSubState();
FlxG.state.openSubState(new ModdingSubstate());
2021-02-24 23:32:51 +00:00
}
}
}
}