converting shit to new options menu

This commit is contained in:
Cameron Taylor 2021-03-24 16:44:58 -04:00
parent 6def44b83c
commit 985bd5374b
5 changed files with 133 additions and 54 deletions

View file

@ -47,9 +47,9 @@ class ColorpickSubstate extends MusicBeatSubstate
FlxG.state.openSubState(new OptionsSubState()); FlxG.state.openSubState(new OptionsSubState());
} }
if (controls.RIGHT_P) if (controls.UI_RIGHT_P)
curSelected += 1; curSelected += 1;
if (controls.LEFT_P) if (controls.UI_LEFT_P)
curSelected -= 1; curSelected -= 1;
if (curSelected < 0) if (curSelected < 0)
@ -57,13 +57,13 @@ class ColorpickSubstate extends MusicBeatSubstate
if (curSelected >= grpNotes.members.length) if (curSelected >= grpNotes.members.length)
curSelected = 0; curSelected = 0;
if (controls.UP) if (controls.UI_UP)
{ {
grpNotes.members[curSelected].colorSwap.update(elapsed * 0.3); grpNotes.members[curSelected].colorSwap.update(elapsed * 0.3);
Note.arrowColors[curSelected] += elapsed * 0.3; Note.arrowColors[curSelected] += elapsed * 0.3;
} }
if (controls.DOWN) if (controls.UI_DOWN)
{ {
grpNotes.members[curSelected].colorSwap.update(-elapsed * 0.3); grpNotes.members[curSelected].colorSwap.update(-elapsed * 0.3);
Note.arrowColors[curSelected] += -elapsed * 0.3; Note.arrowColors[curSelected] += -elapsed * 0.3;

View file

@ -35,9 +35,9 @@ class ModdingSubstate extends MusicBeatSubstate
selections(); selections();
if (controls.UP_P) if (controls.UI_UP_P)
selections(-1); selections(-1);
if (controls.DOWN_P) if (controls.UI_DOWN_P)
selections(1); selections(1);
if (FlxG.keys.justPressed.SPACE) if (FlxG.keys.justPressed.SPACE)

View file

@ -43,10 +43,10 @@ class OptionsSubState extends MusicBeatSubstate
{ {
super.update(elapsed); super.update(elapsed);
if (controls.UP_P) if (controls.UI_UP_P)
curSelected -= 1; curSelected -= 1;
if (controls.DOWN_P) if (controls.UI_DOWN_P)
curSelected += 1; curSelected += 1;
if (curSelected < 0) if (curSelected < 0)

73
source/ui/ColorsMenu.hx Normal file
View file

@ -0,0 +1,73 @@
package ui;
import flixel.FlxG;
import flixel.addons.effects.chainable.FlxEffectSprite;
import flixel.addons.effects.chainable.FlxOutlineEffect;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.util.FlxColor;
class ColorsMenu extends ui.OptionsState.Page
{
var curSelected:Int = 0;
var grpNotes:FlxTypedGroup<Note>;
public function new()
{
super();
grpNotes = new FlxTypedGroup<Note>();
add(grpNotes);
for (i in 0...4)
{
var note:Note = new Note(0, i);
note.x = (100 * i) + i;
note.screenCenter(Y);
var _effectSpr:FlxEffectSprite = new FlxEffectSprite(note, [new FlxOutlineEffect(FlxOutlineMode.FAST, FlxColor.WHITE, 4, 1)]);
add(_effectSpr);
_effectSpr.y = 0;
_effectSpr.x = i * 80;
_effectSpr.antialiasing = true;
_effectSpr.setGraphicSize(Std.int(_effectSpr.width * 0.7));
_effectSpr.updateHitbox();
grpNotes.add(note);
}
}
override function update(elapsed:Float)
{
if (controls.BACK)
{
FlxG.state.closeSubState();
FlxG.state.openSubState(new OptionsSubState());
}
if (controls.UI_RIGHT_P)
curSelected += 1;
if (controls.UI_LEFT_P)
curSelected -= 1;
if (curSelected < 0)
curSelected = grpNotes.members.length - 1;
if (curSelected >= grpNotes.members.length)
curSelected = 0;
if (controls.UI_UP)
{
grpNotes.members[curSelected].colorSwap.update(elapsed * 0.3);
Note.arrowColors[curSelected] += elapsed * 0.3;
}
if (controls.UI_DOWN)
{
grpNotes.members[curSelected].colorSwap.update(-elapsed * 0.3);
Note.arrowColors[curSelected] += -elapsed * 0.3;
}
super.update(elapsed);
}
}

View file

@ -1,22 +1,22 @@
package ui; package ui;
import flixel.FlxSubState;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.FlxSubState;
import flixel.addons.transition.FlxTransitionableState;
import flixel.group.FlxGroup; import flixel.group.FlxGroup;
import flixel.util.FlxSignal; import flixel.util.FlxSignal;
import flixel.addons.transition.FlxTransitionableState;
// typedef OptionsState = OptionsMenu_old; // typedef OptionsState = OptionsMenu_old;
// class OptionsState_new extends MusicBeatState // class OptionsState_new extends MusicBeatState
class OptionsState extends MusicBeatState class OptionsState extends MusicBeatState
{ {
var pages = new Map<PageName, Page>(); var pages = new Map<PageName, Page>();
var currentName:PageName = #if newgrounds Options #else Controls #end; var currentName:PageName = #if newgrounds Options #else Controls #end;
var currentPage(get, never):Page; var currentPage(get, never):Page;
inline function get_currentPage() return pages[currentName];
inline function get_currentPage()
return pages[currentName];
override function create() override function create()
{ {
@ -30,11 +30,13 @@ class OptionsState extends MusicBeatState
var options = addPage(Options, new OptionsMenu(false)); var options = addPage(Options, new OptionsMenu(false));
var controls = addPage(Controls, new ControlsMenu()); var controls = addPage(Controls, new ControlsMenu());
var colors = addPage(Colors, new ColorsMenu());
if (options.hasMultipleOptions()) if (options.hasMultipleOptions())
{ {
options.onExit.add(exitToMainMenu); options.onExit.add(exitToMainMenu);
controls.onExit.add(switchPage.bind(Options)); controls.onExit.add(switchPage.bind(Options));
colors.onExit.add(switchPage.bind(Options));
} }
else else
{ {
@ -98,7 +100,9 @@ class Page extends FlxGroup
public var canExit = true; public var canExit = true;
var controls(get, never):Controls; var controls(get, never):Controls;
inline function get_controls() return PlayerSettings.player1.controls;
inline function get_controls()
return PlayerSettings.player1.controls;
var subState:FlxSubState; var subState:FlxSubState;
@ -161,6 +165,7 @@ class OptionsMenu extends Page
add(items = new TextMenuList()); add(items = new TextMenuList());
createItem("controls", function() switchPage(Controls)); createItem("controls", function() switchPage(Controls));
createItem('colors', function() switchPage(Colors));
#if CAN_OPEN_LINKS #if CAN_OPEN_LINKS
if (showDonate) if (showDonate)
{ {
@ -257,4 +262,5 @@ enum PageName
{ {
Options; Options;
Controls; Controls;
Colors;
} }