mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-26 17:46:08 -05:00
controls.txt and options UI
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"
This commit is contained in:
parent
23ddc9b2f4
commit
e8720332ec
2 changed files with 74 additions and 4 deletions
|
@ -22,7 +22,7 @@ class MainMenuState extends MusicBeatState
|
|||
var menuItems:FlxTypedGroup<FlxSprite>;
|
||||
|
||||
#if !switch
|
||||
var optionShit:Array<String> = ['story mode', 'freeplay', 'donate'];
|
||||
var optionShit:Array<String> = ['story mode', 'freeplay', 'donate', 'options'];
|
||||
#else
|
||||
var optionShit:Array<String> = ['story mode', 'freeplay'];
|
||||
#end
|
||||
|
|
|
@ -1,14 +1,29 @@
|
|||
package;
|
||||
|
||||
import flash.text.TextField;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
import lime.utils.Assets;
|
||||
|
||||
class OptionsMenu extends MusicBeatState
|
||||
{
|
||||
|
||||
var selector:FlxText;
|
||||
var curSelected:Int = 0;
|
||||
|
||||
var controlsStrings:Array<String> = [];
|
||||
|
||||
private var grpControls:FlxTypedGroup<Alphabet>;
|
||||
|
||||
override function create()
|
||||
{
|
||||
var menuBG:FlxSprite = new FlxSprite().loadGraphic('assets/images/menuDesat.png');
|
||||
controlsStrings = CoolUtil.coolTextFile('assets/data/controls.txt');
|
||||
menuBG.color = 0xFFea71fd;
|
||||
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
|
||||
menuBG.updateHitbox();
|
||||
|
@ -16,14 +31,69 @@ class OptionsMenu extends MusicBeatState
|
|||
menuBG.antialiasing = true;
|
||||
add(menuBG);
|
||||
|
||||
grpControls = new FlxTypedGroup<Alphabet>();
|
||||
add(grpControls);
|
||||
|
||||
for (i in 0...controlsStrings.length)
|
||||
{
|
||||
if(controlsStrings[i].indexOf('set') != -1){
|
||||
var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i].substring(3)+': '+controlsStrings[i+1], true, false);
|
||||
controlLabel.isMenuItem = true;
|
||||
controlLabel.targetY = i;
|
||||
grpControls.add(controlLabel);
|
||||
}
|
||||
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
|
||||
}
|
||||
|
||||
super.create();
|
||||
}
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
if (controls.BACK)
|
||||
FlxG.switchState(new MainMenuState());
|
||||
if(controls.UP_P)
|
||||
changeSelection(-1);
|
||||
if(controls.DOWN_P)
|
||||
changeSelection(1);
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
function changeSelection(change:Int = 0)
|
||||
{
|
||||
#if !switch
|
||||
NGio.logEvent('Fresh');
|
||||
#end
|
||||
|
||||
FlxG.sound.play('assets/sounds/scrollMenu' + TitleState.soundExt, 0.4);
|
||||
|
||||
curSelected += change;
|
||||
|
||||
if (curSelected < 0)
|
||||
curSelected = controlsStrings.length - 1;
|
||||
if (curSelected >= controlsStrings.length)
|
||||
curSelected = 0;
|
||||
|
||||
// selector.y = (70 * curSelected) + 30;
|
||||
|
||||
var bullShit:Int = 0;
|
||||
|
||||
for (item in grpControls.members)
|
||||
{
|
||||
item.targetY = bullShit - curSelected;
|
||||
bullShit++;
|
||||
|
||||
item.alpha = 0.6;
|
||||
// item.setGraphicSize(Std.int(item.width * 0.8));
|
||||
|
||||
if (item.targetY == 0)
|
||||
{
|
||||
item.alpha = 1;
|
||||
// item.setGraphicSize(Std.int(item.width));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue