Skip to content

Commit

Permalink
options menu in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Feb 24, 2021
1 parent 88c26f9 commit f86dc69
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- ____________________________ Window Settings ___________________________ -->

<!--These window settings apply to all targets-->
<window width="1280" height="720" fps="60" background="#000000" hardware="true" vsync="false" />
<window width="1280" height="720" fps="" background="#000000" hardware="true" vsync="false" />

<!--HTML5-specific-->
<window if="html5" resizable="true" />
Expand Down
File renamed without changes
4 changes: 4 additions & 0 deletions source/ControlsSubState.hx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package;

import flixel.FlxSprite;
import flixel.FlxSubState;

class ControlsSubState extends FlxSubState
{
public function new()
{
super();

var bullshit = new FlxSprite().makeGraphic(100, 100);
add(bullshit);
}
}
4 changes: 3 additions & 1 deletion source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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
Expand Down Expand Up @@ -174,6 +174,8 @@ class MainMenuState extends MusicBeatState
trace("Freeplay Menu Selected");

case 'options':
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
FlxG.switchState(new OptionsMenu());
}
});
Expand Down
6 changes: 6 additions & 0 deletions source/Options.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package;

class Options
{
public static var masterVolume:Float = 1;
}
58 changes: 32 additions & 26 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,50 @@ class OptionsMenu extends MusicBeatState
menuBG.antialiasing = true;
add(menuBG);

grpControls = new FlxTypedGroup<Alphabet>();
add(grpControls);
/*
grpControls = new FlxTypedGroup<Alphabet>();
add(grpControls);
for (i in 0...controlsStrings.length)
{
if (controlsStrings[i].indexOf('set') != -1)
for (i in 0...controlsStrings.length)
{
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);
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() !!
}
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
}
*/

super.create();

openSubState(new OptionsSubState());
}

override function update(elapsed:Float)
{
super.update(elapsed);

if (controls.ACCEPT)
{
changeBinding();
}
/*
if (controls.ACCEPT)
{
changeBinding();
}
if (isSettingControl)
waitingInput();
else
{
if (controls.BACK)
FlxG.switchState(new MainMenuState());
if (controls.UP_P)
changeSelection(-1);
if (controls.DOWN_P)
changeSelection(1);
}
if (isSettingControl)
waitingInput();
else
{
if (controls.BACK)
FlxG.switchState(new MainMenuState());
if (controls.UP_P)
changeSelection(-1);
if (controls.DOWN_P)
changeSelection(1);
}
*/
}

function waitingInput():Void
Expand Down
61 changes: 60 additions & 1 deletion source/OptionsSubState.hx
Original file line number Diff line number Diff line change
@@ -1,11 +1,70 @@
package;

import flixel.FlxG;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.text.FlxText;
import flixel.util.FlxColor;

class OptionsSubState extends MusicBeatSubstate
{
var textMenuItems:Array<String> = ['Master Volume', 'Sound Volume'];
var textMenuItems:Array<String> = ['Master Volume', 'Sound Volume', 'Controls'];

var selector:FlxSprite;
var curSelected:Int = 0;

var grpOptionsTexts:FlxTypedGroup<FlxText>;

public function new()
{
super();

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());
}
}
}
}

0 comments on commit f86dc69

Please sign in to comment.