keybinds settings
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
package funkin.options;
|
||||
|
||||
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import funkin.ui.Alphabet;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxG;
|
||||
|
||||
using StringTools;
|
||||
|
||||
class KeybindsOptions extends MusicBeatState {
|
||||
public var categories = [
|
||||
{
|
||||
name: 'Notes',
|
||||
settings: [
|
||||
{
|
||||
name: '{noteLeft}',
|
||||
control: 'LEFT'
|
||||
},
|
||||
{
|
||||
name: '{noteDown}',
|
||||
control: 'DOWN'
|
||||
},
|
||||
{
|
||||
name: '{noteUp}',
|
||||
control: 'UP'
|
||||
},
|
||||
{
|
||||
name: '{noteRight}',
|
||||
control: 'RIGHT'
|
||||
},
|
||||
{
|
||||
name: 'Reset',
|
||||
control: 'RESET'
|
||||
},
|
||||
{
|
||||
name: 'Pause',
|
||||
control: 'PAUSE'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'UI',
|
||||
settings: [
|
||||
{
|
||||
name: 'Accept',
|
||||
control: 'ACCEPT'
|
||||
},
|
||||
{
|
||||
name: 'Back',
|
||||
control: 'BACK'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
public var curSelected:Int = -1;
|
||||
public var alphabets:FlxTypedGroup<FlxSprite>;
|
||||
public var bg:FlxSprite;
|
||||
public var coloredBG:FlxSprite;
|
||||
public var noteColors:Array<FlxColor> = [
|
||||
0xFFC24B99,
|
||||
0xFF00FFFF,
|
||||
0xFF12FA05,
|
||||
0xFFF9393F
|
||||
];
|
||||
public var camFollow:FlxObject = new FlxObject(0, 0, 2, 2);
|
||||
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
alphabets = new FlxTypedGroup<FlxSprite>();
|
||||
bg = new FlxSprite(-80).loadGraphic(Paths.image('menuBGBlue'));
|
||||
coloredBG = new FlxSprite(-80).loadGraphic(Paths.image('menuDesat'));
|
||||
for(bg in [bg, coloredBG]) {
|
||||
bg.scrollFactor.set();
|
||||
bg.scale.set(1.15, 1.15);
|
||||
bg.updateHitbox();
|
||||
bg.screenCenter();
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
}
|
||||
coloredBG.alpha = 0;
|
||||
|
||||
var k:Int = 0;
|
||||
for(category in categories) {
|
||||
k++;
|
||||
var title = new Alphabet(0, k * 75, category.name, true);
|
||||
title.screenCenter(X);
|
||||
add(title);
|
||||
|
||||
k++;
|
||||
for(e in category.settings) {
|
||||
// TODO!!
|
||||
var xOffset:Float = 200;
|
||||
if (e.name.startsWith('{note')) {// is actually a note!!
|
||||
var note:FlxSprite = new FlxSprite(100, k * 75);
|
||||
note.frames = Paths.getSparrowAtlas('NOTE_assets');
|
||||
var animName = '${switch(e.name) {
|
||||
case '{noteLeft}':
|
||||
"purple";
|
||||
case '{noteDown}':
|
||||
"blue";
|
||||
case '{noteUp}':
|
||||
"green";
|
||||
default:
|
||||
"red";
|
||||
}}0';
|
||||
e.name = e.name.substring(5, e.name.length - 1);
|
||||
note.antialiasing = true;
|
||||
note.animation.addByPrefix('note', animName, 24, true);
|
||||
note.animation.play('note');
|
||||
note.setGraphicSize(75, 75);
|
||||
note.updateHitbox();
|
||||
var min = Math.min(note.scale.x, note.scale.y);
|
||||
note.scale.set(min, min);
|
||||
add(note);
|
||||
}
|
||||
|
||||
var text = new Alphabet(0, k * 75, e.name, true);
|
||||
text.x = xOffset;
|
||||
alphabets.add(text);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
add(alphabets);
|
||||
changeSelection(1);
|
||||
|
||||
FlxG.camera.follow(camFollow, LOCKON, 0.125);
|
||||
add(camFollow);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
|
||||
if (curSelected < 4) {
|
||||
if (coloredBG.alpha == 0)
|
||||
coloredBG.color = noteColors[curSelected];
|
||||
else
|
||||
coloredBG.color = CoolUtil.lerpColor(coloredBG.color, noteColors[curSelected], 0.0625);
|
||||
|
||||
coloredBG.alpha = lerp(coloredBG.alpha, 1, 0.0625);
|
||||
} else
|
||||
coloredBG.alpha = lerp(coloredBG.alpha, 0, 0.0625);
|
||||
|
||||
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
|
||||
|
||||
if (controls.BACK) {
|
||||
FlxTransitionableState.skipNextTransIn = true;
|
||||
FlxTransitionableState.skipNextTransOut = true;
|
||||
FlxG.switchState(new OptionsMenu());
|
||||
}
|
||||
}
|
||||
|
||||
public function changeSelection(change:Int) {
|
||||
if (change == 0) return;
|
||||
CoolUtil.playMenuSFX(0, 0.4);
|
||||
curSelected = FlxMath.wrap(curSelected + change, 0, alphabets.length-1);
|
||||
alphabets.forEach(function(e) {
|
||||
e.alpha = 0.6;
|
||||
});
|
||||
if (alphabets.members[curSelected] != null) {
|
||||
var alphabet = alphabets.members[curSelected];
|
||||
alphabet.alpha = 1;
|
||||
var minH = FlxG.height / 2;
|
||||
var maxH = alphabets.members[alphabets.length-1].y + alphabets.members[alphabets.length-1].height - (FlxG.height / 2);
|
||||
if (minH < maxH)
|
||||
camFollow.setPosition(FlxG.width / 2, FlxMath.bound(alphabet.y + (alphabet.height / 2) + 75, minH, maxH));
|
||||
else
|
||||
camFollow.setPosition(FlxG.width / 2, FlxG.height / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KeybindSetting extends FlxTypedGroup<FlxSprite> {
|
||||
public var title:Alphabet;
|
||||
public var bind1:Alphabet;
|
||||
public function new(x:Float, y:Float, name:String, value:String, ?sparrowIcon:String, ?sparrowAnim:String) {
|
||||
super();
|
||||
title = new Alphabet(0, 0, name, true);
|
||||
title.setPosition(100, 0);
|
||||
add(title);
|
||||
|
||||
for(i in 1...2) {
|
||||
var b = null;
|
||||
if (i == 1)
|
||||
b = bind1 = new Alphabet(0, 0, "", false);
|
||||
else
|
||||
b = bind2 = new Alphabet(0, 0, "", false);
|
||||
b.text = "test";
|
||||
b.x = FlxG.width * (0.25 * (i+1));
|
||||
add(b);
|
||||
}
|
||||
setPosition(x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package funkin.options;
|
||||
|
||||
import flixel.util.FlxSave;
|
||||
import flixel.input.keyboard.FlxKey;
|
||||
|
||||
class Options
|
||||
{
|
||||
@:dox(hide) public static var __save:FlxSave;
|
||||
|
||||
/**
|
||||
* GAMEPLAY SETTINGS
|
||||
*/
|
||||
public static var naughtyness:Bool = true;
|
||||
public static var downscroll:Bool = false;
|
||||
public static var flashingMenu:Bool = true;
|
||||
public static var camZoomOnBeat:Bool = true;
|
||||
public static var fpsCounter:Bool = true;
|
||||
public static var autoPause:Bool = true;
|
||||
|
||||
/**
|
||||
* PLAYER 1 CONTROLS
|
||||
*/
|
||||
public static var P1_LEFT:Array<FlxKey> = [A];
|
||||
public static var P1_DOWN:Array<FlxKey> = [S];
|
||||
public static var P1_UP:Array<FlxKey> = [W];
|
||||
public static var P1_RIGHT:Array<FlxKey> = [D];
|
||||
public static var P1_ACCEPT:Array<FlxKey> = [Z, SPACE, ENTER];
|
||||
public static var P1_BACK:Array<FlxKey> = [BACKSPACE, ESCAPE];
|
||||
public static var P1_PAUSE:Array<FlxKey> = [ESCAPE, ENTER, P];
|
||||
public static var P1_RESET:Array<FlxKey> = [R];
|
||||
|
||||
/**
|
||||
* PLAYER 2 CONTROLS (ALT)
|
||||
*/
|
||||
public static var P2_LEFT:Array<FlxKey> = [LEFT];
|
||||
public static var P2_DOWN:Array<FlxKey> = [DOWN];
|
||||
public static var P2_UP:Array<FlxKey> = [UP];
|
||||
public static var P2_RIGHT:Array<FlxKey> = [RIGHT];
|
||||
public static var P2_ACCEPT:Array<FlxKey> = [];
|
||||
public static var P2_BACK:Array<FlxKey> = [];
|
||||
public static var P2_PAUSE:Array<FlxKey> = [];
|
||||
public static var P2_RESET:Array<FlxKey> = [];
|
||||
|
||||
/**
|
||||
* SOLO GETTERS & SETTERS
|
||||
*/
|
||||
public static var SOLO_LEFT(get, null):Array<FlxKey>;
|
||||
public static var SOLO_DOWN(get, null):Array<FlxKey>;
|
||||
public static var SOLO_UP(get, null):Array<FlxKey>;
|
||||
public static var SOLO_RIGHT(get, null):Array<FlxKey>;
|
||||
public static var SOLO_ACCEPT(get, null):Array<FlxKey>;
|
||||
public static var SOLO_BACK(get, null):Array<FlxKey>;
|
||||
public static var SOLO_PAUSE(get, null):Array<FlxKey>;
|
||||
public static var SOLO_RESET(get, null):Array<FlxKey>;
|
||||
|
||||
// GETTERS REGION
|
||||
#if REGION
|
||||
private static function get_SOLO_LEFT() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_LEFT) a.push(e);
|
||||
for(e in P2_LEFT) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_DOWN() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_DOWN) a.push(e);
|
||||
for(e in P2_DOWN) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_UP() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_UP) a.push(e);
|
||||
for(e in P2_UP) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_RIGHT() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_RIGHT) a.push(e);
|
||||
for(e in P2_RIGHT) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_ACCEPT() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_ACCEPT) a.push(e);
|
||||
for(e in P2_ACCEPT) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_BACK() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_BACK) a.push(e);
|
||||
for(e in P2_BACK) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_PAUSE() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_PAUSE) a.push(e);
|
||||
for(e in P2_PAUSE) a.push(e);
|
||||
return a;
|
||||
}
|
||||
private static function get_SOLO_RESET() {
|
||||
var a:Array<FlxKey> = [];
|
||||
for(e in P1_RESET) a.push(e);
|
||||
for(e in P2_RESET) a.push(e);
|
||||
return a;
|
||||
}
|
||||
#end
|
||||
|
||||
public static function load() {
|
||||
__save = new FlxSave();
|
||||
__save.bind("options");
|
||||
for(field in Reflect.fields(__save.data)) {
|
||||
var obj = Reflect.field(__save.data, field);
|
||||
Reflect.setProperty(Options, field, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function save() {
|
||||
for(field in Reflect.fields(Options)) {
|
||||
var obj = Reflect.field(Options, field);
|
||||
if (Reflect.isFunction(obj) || obj is FlxSave) continue;
|
||||
Reflect.setField(__save.data, field, obj);
|
||||
}
|
||||
__save.flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package funkin.options;
|
||||
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import funkin.ui.Alphabet;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxG;
|
||||
import flixel.effects.FlxFlicker;
|
||||
|
||||
class OptionsMenu extends MusicBeatState {
|
||||
public var options = [
|
||||
{
|
||||
name: 'Controls',
|
||||
desc: 'Change Controls for Player 1 and Player 2!',
|
||||
state: funkin.options.KeybindsOptions
|
||||
},
|
||||
{
|
||||
name: 'Visuals',
|
||||
desc: 'Change Gameplay options such as Downscroll, Scroll Speed...',
|
||||
state: null
|
||||
}
|
||||
];
|
||||
|
||||
public var curSelected:Int = -1;
|
||||
public var canSelect:Bool = true;
|
||||
public var alphabets:FlxTypedGroup<Alphabet>;
|
||||
public override function create() {
|
||||
var bg:FlxSprite = new FlxSprite(-80).loadGraphic(Paths.image('menuBGBlue'));
|
||||
bg.scrollFactor.set();
|
||||
bg.scale.set(1.15, 1.15);
|
||||
bg.updateHitbox();
|
||||
bg.screenCenter();
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
|
||||
super.create();
|
||||
alphabets = new FlxTypedGroup<Alphabet>();
|
||||
for(k=>e in options) {
|
||||
var alphabet = new Alphabet(0, (k+1) * 100, e.name, true, false);
|
||||
alphabet.screenCenter(X);
|
||||
alphabets.add(alphabet);
|
||||
}
|
||||
add(alphabets);
|
||||
changeSelection(1);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (!canSelect) return;
|
||||
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
|
||||
if (controls.ACCEPT && alphabets.members[curSelected] != null) {
|
||||
CoolUtil.playMenuSFX(1);
|
||||
FlxFlicker.flicker(alphabets.members[curSelected], 1, 0.06, false, false, function(flick:FlxFlicker)
|
||||
{
|
||||
FlxTransitionableState.skipNextTransIn = true;
|
||||
FlxTransitionableState.skipNextTransOut = true;
|
||||
FlxG.switchState(Type.createInstance(options[curSelected].state, []));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function changeSelection(change:Int) {
|
||||
if (change == 0) return;
|
||||
CoolUtil.playMenuSFX(0, 0.4);
|
||||
curSelected = FlxMath.wrap(curSelected + change, 0, options.length-1);
|
||||
alphabets.forEach(function(e) {
|
||||
e.alpha = 0.6;
|
||||
});
|
||||
if (alphabets.members[curSelected] != null) alphabets.members[curSelected].alpha = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package funkin.options;
|
||||
|
||||
/**
|
||||
* Direct replica from Week 7 lol
|
||||
*/
|
||||
class OptionsScreen extends MusicBeatState {
|
||||
public static inline var defaultBGColor:FlxColor = 0xFFFDE871;
|
||||
|
||||
public var bgColor:FlxColor = 0xFFFDE871;
|
||||
public var bg:FlxSprite;
|
||||
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user