diff --git a/buildnumber.txt b/buildnumber.txt index b14de3ad..82a1667b 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -421 \ No newline at end of file +426 \ No newline at end of file diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index 16951808..550f0c09 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -1,11 +1,13 @@ package funkin.options; +import openfl.Lib; import flixel.util.FlxSave; import flixel.input.keyboard.FlxKey; class Options { @:dox(hide) public static var __save:FlxSave; + @:dox(hide) private static var __eventAdded = false; /** * GAMEPLAY SETTINGS @@ -24,9 +26,9 @@ class Options public static var P1_DOWN:Array = [S]; public static var P1_UP:Array = [W]; public static var P1_RIGHT:Array = [D]; - public static var P1_ACCEPT:Array = [Z, SPACE, ENTER]; - public static var P1_BACK:Array = [BACKSPACE, ESCAPE]; - public static var P1_PAUSE:Array = [ESCAPE, ENTER, P]; + public static var P1_ACCEPT:Array = [ENTER]; + public static var P1_BACK:Array = [BACKSPACE]; + public static var P1_PAUSE:Array = [ENTER]; public static var P1_RESET:Array = [R]; /** @@ -36,9 +38,9 @@ class Options public static var P2_DOWN:Array = [DOWN]; public static var P2_UP:Array = [UP]; public static var P2_RIGHT:Array = [RIGHT]; - public static var P2_ACCEPT:Array = []; - public static var P2_BACK:Array = []; - public static var P2_PAUSE:Array = []; + public static var P2_ACCEPT:Array = [SPACE]; + public static var P2_BACK:Array = [ESCAPE]; + public static var P2_PAUSE:Array = [ESCAPE]; public static var P2_RESET:Array = []; /** @@ -104,7 +106,6 @@ class Options return a; } #end - public static function load() { __save = new FlxSave(); __save.bind("options"); @@ -112,6 +113,13 @@ class Options var obj = Reflect.field(__save.data, field); Reflect.setProperty(Options, field, obj); } + + if (!__eventAdded) { + Lib.application.onExit.add(function(i:Int) { + save(); + }); + __eventAdded = true; + } } public static function save() { diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index cca5e8d1..d2d5d5e6 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -60,7 +60,6 @@ class OptionsMenu extends MusicBeatState { 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, [])); }); diff --git a/source/funkin/options/keybinds/ChangeKeybindSubState.hx b/source/funkin/options/keybinds/ChangeKeybindSubState.hx index 885b73ff..3ac55bec 100644 --- a/source/funkin/options/keybinds/ChangeKeybindSubState.hx +++ b/source/funkin/options/keybinds/ChangeKeybindSubState.hx @@ -25,7 +25,6 @@ class ChangeKeybindSubState extends MusicBeatSubstate { } public override function create() { super.create(); - } public override function update(elapsed:Float) { diff --git a/source/funkin/options/keybinds/KeybindSetting.hx b/source/funkin/options/keybinds/KeybindSetting.hx index bae5422c..310f7fc1 100644 --- a/source/funkin/options/keybinds/KeybindSetting.hx +++ b/source/funkin/options/keybinds/KeybindSetting.hx @@ -72,8 +72,8 @@ class KeybindSetting extends FlxTypedSpriteGroup { public override function update(elapsed:Float) { super.update(elapsed); - bind1.alpha = (p2Selected ? 0.6 : 1) / alpha; - bind2.alpha = (p2Selected ? 1 : 0.6) / alpha; + bind1.alpha = (p2Selected ? 0.55 : 1) / alpha; + bind2.alpha = (p2Selected ? 1 : 0.55) / alpha; bind1.alpha *= alpha; bind2.alpha *= alpha; } @@ -94,6 +94,7 @@ class KeybindSetting extends FlxTypedSpriteGroup { Reflect.setField(Options, 'P2_$value', [option2 = 0]); else Reflect.setField(Options, 'P1_$value', [option1 = 0]); + cancelCallback(); })); } diff --git a/source/funkin/options/keybinds/KeybindsOptions.hx b/source/funkin/options/keybinds/KeybindsOptions.hx index ad3382ed..21b214b9 100644 --- a/source/funkin/options/keybinds/KeybindsOptions.hx +++ b/source/funkin/options/keybinds/KeybindsOptions.hx @@ -26,20 +26,49 @@ class KeybindsOptions extends MusicBeatSubstate { settings: [ { name: '{noteLeft}', - control: 'LEFT' + control: 'NOTE_LEFT' }, { name: '{noteDown}', - control: 'DOWN' + control: 'NOTE_DOWN' }, { name: '{noteUp}', - control: 'UP' + control: 'NOTE_UP' }, { name: '{noteRight}', + control: 'NOTE_RIGHT' + }, + ] + }, + { + name: 'UI', + settings: [ + { + name: 'Left', + control: 'LEFT' + }, + { + name: 'Down', + control: 'DOWN' + }, + { + name: 'Up', + control: 'UP' + }, + { + name: 'Right', control: 'RIGHT' }, + { + name: 'Accept', + control: 'ACCEPT' + }, + { + name: 'Back', + control: 'BACK' + }, { name: 'Reset', control: 'RESET' @@ -49,19 +78,6 @@ class KeybindsOptions extends MusicBeatSubstate { control: 'PAUSE' }, ] - }, - { - name: 'UI', - settings: [ - { - name: 'Accept', - control: 'ACCEPT' - }, - { - name: 'Back', - control: 'BACK' - } - ] } ]; @@ -188,7 +204,6 @@ class KeybindsOptions extends MusicBeatSubstate { changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0)); if (controls.BACK) { FlxTransitionableState.skipNextTransIn = true; - FlxTransitionableState.skipNextTransOut = true; if (isSubState) close(); else @@ -228,7 +243,7 @@ class KeybindsOptions extends MusicBeatSubstate { CoolUtil.playMenuSFX(0, 0.4); curSelected = FlxMath.wrap(curSelected + change, 0, alphabets.length-1); alphabets.forEach(function(e) { - e.alpha = 0.6; + e.alpha = 0.55; }); if (alphabets.members[curSelected] != null) { var alphabet = alphabets.members[curSelected]; diff --git a/source/funkin/system/Controls.hx b/source/funkin/system/Controls.hx index c50fff35..1b0054e0 100644 --- a/source/funkin/system/Controls.hx +++ b/source/funkin/system/Controls.hx @@ -12,9 +12,7 @@ import flixel.input.gamepad.FlxGamepadButton; import flixel.input.gamepad.FlxGamepadInputID; import flixel.input.keyboard.FlxKey; -#if (haxe >= "4.0.0") -enum abstract Action(String) to String from String -{ +enum abstract Action(String) to String from String { var UP = "up"; var LEFT = "left"; var RIGHT = "right"; @@ -27,35 +25,27 @@ enum abstract Action(String) to String from String var LEFT_R = "left-release"; var RIGHT_R = "right-release"; var DOWN_R = "down-release"; + + + var NOTE_UP = "note-up"; + var NOTE_LEFT = "note-left"; + var NOTE_RIGHT = "note-right"; + var NOTE_DOWN = "note-down"; + var NOTE_UP_P = "note-up-press"; + var NOTE_LEFT_P = "note-left-press"; + var NOTE_RIGHT_P = "note-right-press"; + var NOTE_DOWN_P = "note-down-press"; + var NOTE_UP_R = "note-up-release"; + var NOTE_LEFT_R = "note-left-release"; + var NOTE_RIGHT_R = "note-right-release"; + var NOTE_DOWN_R = "note-down-release"; + var ACCEPT = "accept"; var BACK = "back"; var PAUSE = "pause"; var RESET = "reset"; var CHEAT = "cheat"; } -#else -@:enum -abstract Action(String) to String from String -{ - var UP = "up"; - var LEFT = "left"; - var RIGHT = "right"; - var DOWN = "down"; - var UP_P = "up-press"; - var LEFT_P = "left-press"; - var RIGHT_P = "right-press"; - var DOWN_P = "down-press"; - var UP_R = "up-release"; - var LEFT_R = "left-release"; - var RIGHT_R = "right-release"; - var DOWN_R = "down-release"; - var ACCEPT = "accept"; - var BACK = "back"; - var PAUSE = "pause"; - var RESET = "reset"; - var CHEAT = "cheat"; -} -#end enum Device { @@ -74,6 +64,10 @@ enum Control LEFT; RIGHT; DOWN; + NOTE_UP; + NOTE_LEFT; + NOTE_RIGHT; + NOTE_DOWN; RESET; ACCEPT; BACK; @@ -107,6 +101,20 @@ class Controls extends FlxActionSet var _leftR = new FlxActionDigital(Action.LEFT_R); var _rightR = new FlxActionDigital(Action.RIGHT_R); var _downR = new FlxActionDigital(Action.DOWN_R); + + var _noteUp = new FlxActionDigital(Action.NOTE_UP); + var _noteLeft = new FlxActionDigital(Action.NOTE_LEFT); + var _noteRight = new FlxActionDigital(Action.NOTE_RIGHT); + var _noteDown = new FlxActionDigital(Action.NOTE_DOWN); + var _noteUpP = new FlxActionDigital(Action.NOTE_UP_P); + var _noteLeftP = new FlxActionDigital(Action.NOTE_LEFT_P); + var _noteRightP = new FlxActionDigital(Action.NOTE_RIGHT_P); + var _noteDownP = new FlxActionDigital(Action.NOTE_DOWN_P); + var _noteUpR = new FlxActionDigital(Action.NOTE_UP_R); + var _noteLeftR = new FlxActionDigital(Action.NOTE_LEFT_R); + var _noteRightR = new FlxActionDigital(Action.NOTE_RIGHT_R); + var _noteDownR = new FlxActionDigital(Action.NOTE_DOWN_R); + var _accept = new FlxActionDigital(Action.ACCEPT); var _back = new FlxActionDigital(Action.BACK); var _pause = new FlxActionDigital(Action.PAUSE); @@ -122,65 +130,65 @@ class Controls extends FlxActionSet public var gamepadsAdded:Array = []; public var keyboardScheme = KeyboardScheme.None; - public var UP(get, never):Bool; + public var NOTE_UP(get, never):Bool; - inline function get_UP() - return _up.check(); + inline function get_NOTE_UP() + return _noteUp.check(); - public var LEFT(get, never):Bool; + public var NOTE_LEFT(get, never):Bool; - inline function get_LEFT() - return _left.check(); + inline function get_NOTE_LEFT() + return _noteLeft.check(); - public var RIGHT(get, never):Bool; + public var NOTE_RIGHT(get, never):Bool; - inline function get_RIGHT() - return _right.check(); + inline function get_NOTE_RIGHT() + return _noteRight.check(); - public var DOWN(get, never):Bool; + public var NOTE_DOWN(get, never):Bool; - inline function get_DOWN() - return _down.check(); + inline function get_NOTE_DOWN() + return _noteDown.check(); - public var UP_P(get, never):Bool; + public var NOTE_UP_P(get, never):Bool; - inline function get_UP_P() - return _upP.check(); + inline function get_NOTE_UP_P() + return _noteUpP.check(); - public var LEFT_P(get, never):Bool; + public var NOTE_LEFT_P(get, never):Bool; - inline function get_LEFT_P() - return _leftP.check(); + inline function get_NOTE_LEFT_P() + return _noteLeftP.check(); - public var RIGHT_P(get, never):Bool; + public var NOTE_RIGHT_P(get, never):Bool; - inline function get_RIGHT_P() - return _rightP.check(); + inline function get_NOTE_RIGHT_P() + return _noteRightP.check(); - public var DOWN_P(get, never):Bool; + public var NOTE_DOWN_P(get, never):Bool; - inline function get_DOWN_P() - return _downP.check(); + inline function get_NOTE_DOWN_P() + return _noteDownP.check(); - public var UP_R(get, never):Bool; + public var NOTE_UP_R(get, never):Bool; - inline function get_UP_R() - return _upR.check(); + inline function get_NOTE_UP_R() + return _noteUpR.check(); - public var LEFT_R(get, never):Bool; + public var NOTE_LEFT_R(get, never):Bool; - inline function get_LEFT_R() - return _leftR.check(); + inline function get_NOTE_LEFT_R() + return _noteLeftR.check(); - public var RIGHT_R(get, never):Bool; + public var NOTE_RIGHT_R(get, never):Bool; - inline function get_RIGHT_R() - return _rightR.check(); + inline function get_NOTE_RIGHT_R() + return _noteRightR.check(); - public var DOWN_R(get, never):Bool; + public var NOTE_DOWN_R(get, never):Bool; - inline function get_DOWN_R() - return _downR.check(); + inline function get_NOTE_DOWN_R() + return _noteDownR.check(); public var ACCEPT(get, never):Bool; @@ -207,7 +215,6 @@ class Controls extends FlxActionSet inline function get_CHEAT() return _cheat.check(); - #if (haxe >= "4.0.0") public function new(name, scheme = None) { super(name); @@ -224,6 +231,20 @@ class Controls extends FlxActionSet add(_leftR); add(_rightR); add(_downR); + + add(_noteUp); + add(_noteLeft); + add(_noteRight); + add(_noteDown); + add(_noteUpP); + add(_noteLeftP); + add(_noteRightP); + add(_noteDownP); + add(_noteUpR); + add(_noteLeftR); + add(_noteRightR); + add(_noteDownR); + add(_accept); add(_back); add(_pause); @@ -235,37 +256,6 @@ class Controls extends FlxActionSet setKeyboardScheme(scheme, false); } - #else - public function new(name, scheme:KeyboardScheme = null) - { - super(name); - - add(_up); - add(_left); - add(_right); - add(_down); - add(_upP); - add(_leftP); - add(_rightP); - add(_downP); - add(_upR); - add(_leftR); - add(_rightR); - add(_downR); - add(_accept); - add(_back); - add(_pause); - add(_reset); - add(_cheat); - - for (action in digitalActions) - byName[action.name] = action; - - if (scheme == null) - scheme = None; - setKeyboardScheme(scheme, false); - } - #end override function update() { @@ -306,6 +296,10 @@ class Controls extends FlxActionSet case DOWN: _down; case LEFT: _left; case RIGHT: _right; + case NOTE_UP: _noteUp; + case NOTE_DOWN: _noteDown; + case NOTE_LEFT: _noteLeft; + case NOTE_RIGHT: _noteRight; case ACCEPT: _accept; case BACK: _back; case PAUSE: _pause; @@ -330,6 +324,22 @@ class Controls extends FlxActionSet { switch (control) { + case NOTE_UP: + func(_noteUp, PRESSED); + func(_noteUpP, JUST_PRESSED); + func(_noteUpR, JUST_RELEASED); + case NOTE_LEFT: + func(_noteLeft, PRESSED); + func(_noteLeftP, JUST_PRESSED); + func(_noteLeftR, JUST_RELEASED); + case NOTE_RIGHT: + func(_noteRight, PRESSED); + func(_noteRightP, JUST_PRESSED); + func(_noteRightR, JUST_RELEASED); + case NOTE_DOWN: + func(_noteDown, PRESSED); + func(_noteDownP, JUST_PRESSED); + func(_noteDownR, JUST_RELEASED); case UP: func(_up, PRESSED); func(_upP, JUST_PRESSED);