mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-27 01:55:52 -05:00
converting shit to new options menu
This commit is contained in:
parent
6def44b83c
commit
985bd5374b
5 changed files with 133 additions and 54 deletions
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
73
source/ui/ColorsMenu.hx
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
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()
|
||||||
{
|
{
|
||||||
var menuBG = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
|
var menuBG = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
|
||||||
|
@ -27,14 +27,16 @@ class OptionsState extends MusicBeatState
|
||||||
menuBG.screenCenter();
|
menuBG.screenCenter();
|
||||||
menuBG.scrollFactor.set(0, 0);
|
menuBG.scrollFactor.set(0, 0);
|
||||||
add(menuBG);
|
add(menuBG);
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
|
@ -42,12 +44,12 @@ class OptionsState extends MusicBeatState
|
||||||
controls.onExit.add(exitToMainMenu);
|
controls.onExit.add(exitToMainMenu);
|
||||||
setPage(Controls);
|
setPage(Controls);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable for intro transition
|
// disable for intro transition
|
||||||
currentPage.enabled = false;
|
currentPage.enabled = false;
|
||||||
super.create();
|
super.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPage<T:Page>(name:PageName, page:T)
|
function addPage<T:Page>(name:PageName, page:T)
|
||||||
{
|
{
|
||||||
page.onSwitch.add(switchPage);
|
page.onSwitch.add(switchPage);
|
||||||
|
@ -56,35 +58,35 @@ class OptionsState extends MusicBeatState
|
||||||
page.exists = currentName == name;
|
page.exists = currentName == name;
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPage(name:PageName)
|
function setPage(name:PageName)
|
||||||
{
|
{
|
||||||
if (pages.exists(currentName))
|
if (pages.exists(currentName))
|
||||||
currentPage.exists = false;
|
currentPage.exists = false;
|
||||||
|
|
||||||
currentName = name;
|
currentName = name;
|
||||||
|
|
||||||
if (pages.exists(currentName))
|
if (pages.exists(currentName))
|
||||||
currentPage.exists = true;
|
currentPage.exists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
override function finishTransIn()
|
override function finishTransIn()
|
||||||
{
|
{
|
||||||
super.finishTransIn();
|
super.finishTransIn();
|
||||||
|
|
||||||
currentPage.enabled = true;
|
currentPage.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchPage(name:PageName)
|
function switchPage(name:PageName)
|
||||||
{
|
{
|
||||||
//Todo animate?
|
// Todo animate?
|
||||||
setPage(name);
|
setPage(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function exitToMainMenu()
|
function exitToMainMenu()
|
||||||
{
|
{
|
||||||
currentPage.enabled = false;
|
currentPage.enabled = false;
|
||||||
//Todo animate?
|
// Todo animate?
|
||||||
FlxG.switchState(new MainMenuState());
|
FlxG.switchState(new MainMenuState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,57 +95,59 @@ class Page extends FlxGroup
|
||||||
{
|
{
|
||||||
public var onSwitch(default, null) = new FlxTypedSignal<PageName->Void>();
|
public var onSwitch(default, null) = new FlxTypedSignal<PageName->Void>();
|
||||||
public var onExit(default, null) = new FlxSignal();
|
public var onExit(default, null) = new FlxSignal();
|
||||||
|
|
||||||
public var enabled(default, set) = true;
|
public var enabled(default, set) = true;
|
||||||
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;
|
||||||
|
|
||||||
inline function switchPage(name:PageName)
|
inline function switchPage(name:PageName)
|
||||||
{
|
{
|
||||||
onSwitch.dispatch(name);
|
onSwitch.dispatch(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function exit()
|
inline function exit()
|
||||||
{
|
{
|
||||||
onExit.dispatch();
|
onExit.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
updateEnabled(elapsed);
|
updateEnabled(elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEnabled(elapsed:Float)
|
function updateEnabled(elapsed:Float)
|
||||||
{
|
{
|
||||||
if (canExit && controls.BACK)
|
if (canExit && controls.BACK)
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_enabled(value:Bool)
|
function set_enabled(value:Bool)
|
||||||
{
|
{
|
||||||
return this.enabled = value;
|
return this.enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPrompt(prompt:Prompt, onClose:Void->Void)
|
function openPrompt(prompt:Prompt, onClose:Void->Void)
|
||||||
{
|
{
|
||||||
enabled = false;
|
enabled = false;
|
||||||
prompt.closeCallback = function ()
|
prompt.closeCallback = function()
|
||||||
{
|
{
|
||||||
enabled = true;
|
enabled = true;
|
||||||
if (onClose != null)
|
if (onClose != null)
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
FlxG.state.openSubState(prompt);
|
FlxG.state.openSubState(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
override function destroy()
|
override function destroy()
|
||||||
{
|
{
|
||||||
super.destroy();
|
super.destroy();
|
||||||
|
@ -154,13 +158,14 @@ class Page extends FlxGroup
|
||||||
class OptionsMenu extends Page
|
class OptionsMenu extends Page
|
||||||
{
|
{
|
||||||
var items:TextMenuList;
|
var items:TextMenuList;
|
||||||
|
|
||||||
public function new (showDonate:Bool)
|
public function new(showDonate:Bool)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +181,7 @@ class OptionsMenu extends Page
|
||||||
#end
|
#end
|
||||||
createItem("exit", exit);
|
createItem("exit", exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createItem(name:String, callback:Void->Void, fireInstantly = false)
|
function createItem(name:String, callback:Void->Void, fireInstantly = false)
|
||||||
{
|
{
|
||||||
var item = items.createItem(0, 100 + items.length * 100, name, Bold, callback);
|
var item = items.createItem(0, 100 + items.length * 100, name, Bold, callback);
|
||||||
|
@ -184,13 +189,13 @@ class OptionsMenu extends Page
|
||||||
item.screenCenter(X);
|
item.screenCenter(X);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
override function set_enabled(value:Bool)
|
override function set_enabled(value:Bool)
|
||||||
{
|
{
|
||||||
items.enabled = value;
|
items.enabled = value;
|
||||||
return super.set_enabled(value);
|
return super.set_enabled(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if this page has multiple options, ecluding the exit option.
|
* True if this page has multiple options, ecluding the exit option.
|
||||||
* If false, there's no reason to ever show this page.
|
* If false, there's no reason to ever show this page.
|
||||||
|
@ -199,7 +204,7 @@ class OptionsMenu extends Page
|
||||||
{
|
{
|
||||||
return items.length > 2;
|
return items.length > 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAN_OPEN_LINKS
|
#if CAN_OPEN_LINKS
|
||||||
function selectDonate()
|
function selectDonate()
|
||||||
{
|
{
|
||||||
|
@ -210,18 +215,18 @@ class OptionsMenu extends Page
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if newgrounds
|
#if newgrounds
|
||||||
function selectLogin()
|
function selectLogin()
|
||||||
{
|
{
|
||||||
openNgPrompt(NgPrompt.showLogin());
|
openNgPrompt(NgPrompt.showLogin());
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLogout()
|
function selectLogout()
|
||||||
{
|
{
|
||||||
openNgPrompt(NgPrompt.showLogout());
|
openNgPrompt(NgPrompt.showLogout());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls openPrompt and redraws the login/logout button
|
* Calls openPrompt and redraws the login/logout button
|
||||||
* @param prompt
|
* @param prompt
|
||||||
|
@ -232,16 +237,16 @@ class OptionsMenu extends Page
|
||||||
var onPromptClose = checkLoginStatus;
|
var onPromptClose = checkLoginStatus;
|
||||||
if (onClose != null)
|
if (onClose != null)
|
||||||
{
|
{
|
||||||
onPromptClose = function ()
|
onPromptClose = function()
|
||||||
{
|
{
|
||||||
checkLoginStatus();
|
checkLoginStatus();
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openPrompt(prompt, onPromptClose);
|
openPrompt(prompt, onPromptClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkLoginStatus()
|
function checkLoginStatus()
|
||||||
{
|
{
|
||||||
var prevLoggedIn = items.has("logout");
|
var prevLoggedIn = items.has("logout");
|
||||||
|
@ -257,4 +262,5 @@ enum PageName
|
||||||
{
|
{
|
||||||
Options;
|
Options;
|
||||||
Controls;
|
Controls;
|
||||||
|
Colors;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue