Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2503 from ItzFireable/master
Browse files Browse the repository at this point in the history
More keybinds & fixes
  • Loading branch information
Kade-github authored Oct 12, 2021
2 parents 642c92a + ea5017a commit b8fe0a2
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 39 deletions.
5 changes: 5 additions & 0 deletions source/Caching.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import flixel.math.FlxRect;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import flixel.text.FlxText;
import flixel.input.keyboard.FlxKey;

using StringTools;

Expand Down Expand Up @@ -54,6 +55,10 @@ class Caching extends MusicBeatState

KadeEngineData.initSave();

FlxG.sound.muteKeys = [FlxKey.fromString(FlxG.save.data.muteBind)];
FlxG.sound.volumeDownKeys = [FlxKey.fromString(FlxG.save.data.volDownBind)];
FlxG.sound.volumeUpKeys = [FlxKey.fromString(FlxG.save.data.volUpBind)];

FlxG.mouse.visible = false;

FlxG.worldBounds.set(0, 0);
Expand Down
6 changes: 3 additions & 3 deletions source/Controls.hx
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ class Controls extends FlxActionSet
buttons.set(Control.RIGHT, [FlxGamepadInputID.fromString(FlxG.save.data.gprightBind)]);
buttons.set(Control.ACCEPT, [FlxGamepadInputID.A]);
buttons.set(Control.BACK, [FlxGamepadInputID.B]);
buttons.set(Control.PAUSE, [FlxGamepadInputID.START]);
buttons.set(Control.PAUSE, [FlxGamepadInputID.fromString(FlxG.save.data.gppauseBind)]);

addGamepad(0, buttons);

Expand All @@ -592,8 +592,8 @@ class Controls extends FlxActionSet
inline bindKeys(Control.RIGHT, [FlxKey.fromString(FlxG.save.data.rightBind), FlxKey.RIGHT]);
inline bindKeys(Control.ACCEPT, [Z, SPACE, ENTER]);
inline bindKeys(Control.BACK, [BACKSPACE, ESCAPE]);
inline bindKeys(Control.PAUSE, [ENTER, ESCAPE]);
inline bindKeys(Control.RESET, [FlxKey.fromString(FlxG.save.data.killBind)]);
inline bindKeys(Control.PAUSE, [FlxKey.fromString(FlxG.save.data.pauseBind)]);
inline bindKeys(Control.RESET, [FlxKey.fromString(FlxG.save.data.resetBind)]);
}

function removeKeyboard()
Expand Down
57 changes: 43 additions & 14 deletions source/KeyBindMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,29 @@ class KeyBindMenu extends FlxSubState
var keyTextDisplay:FlxText;
var keyWarning:FlxText;
var warningTween:FlxTween;
var keyText:Array<String> = ["LEFT", "DOWN", "UP", "RIGHT"];
var defaultKeys:Array<String> = ["A", "S", "W", "D", "R"];
var defaultGpKeys:Array<String> = ["DPAD_LEFT", "DPAD_DOWN", "DPAD_UP", "DPAD_RIGHT"];
var keyText:Array<String> = [
"LEFT", "DOWN", "UP", "RIGHT", "PAUSE", "RESET", "MUTE", "VOLUME UP", "VOLUME DOWN", "FULLSCREEN"
];
var defaultKeys:Array<String> = ["A", "S", "W", "D", "ENTER", "R", "NUMPADZERO", "NUMPADMINUS", "NUMPADPLUS", "F"];
var defaultGpKeys:Array<String> = ["DPAD_LEFT", "DPAD_DOWN", "DPAD_UP", "DPAD_RIGHT", "START", "SELECT"];
var curSelected:Int = 0;

var keys:Array<String> = [
FlxG.save.data.leftBind,
FlxG.save.data.downBind,
FlxG.save.data.upBind,
FlxG.save.data.rightBind
FlxG.save.data.leftBind, FlxG.save.data.downBind, FlxG.save.data.upBind, FlxG.save.data.rightBind, FlxG.save.data.pauseBind, FlxG.save.data.resetBind,
FlxG.save.data.muteBind, FlxG.save.data.volUpBind, FlxG.save.data.volDownBind, FlxG.save.data.fullscreenBind
];

var gpKeys:Array<String> = [
FlxG.save.data.gpleftBind,
FlxG.save.data.gpdownBind,
FlxG.save.data.gpupBind,
FlxG.save.data.gprightBind
FlxG.save.data.gprightBind,
FlxG.save.data.gppauseBind,
FlxG.save.data.gpresetBind
];

var tempKey:String = "";
var blacklist:Array<String> = ["ESCAPE", "ENTER", "BACKSPACE", "SPACE", "TAB"];
var blacklist:Array<String> = ["ESCAPE", "BACKSPACE", "SPACE", "TAB"];

var blackBox:FlxSprite;
var infoText:FlxText;
Expand Down Expand Up @@ -82,7 +86,7 @@ class KeyBindMenu extends FlxSubState
blackBox = new FlxSprite(0, 0).makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
add(blackBox);

infoText = new FlxText(-10, 580, 1280,
infoText = new FlxText(-10, 630, 1280,
'Current Mode: ${KeyBinds.gamepad ? 'GAMEPAD' : 'KEYBOARD'}. Press TAB to switch\n(${KeyBinds.gamepad ? 'RIGHT Trigger' : 'Escape'} to save, ${KeyBinds.gamepad ? 'LEFT Trigger' : 'Backspace'} to leave without saving. ${KeyBinds.gamepad ? 'START To change a keybind' : ''})',
72);
infoText.scrollFactor.set(0, 0);
Expand Down Expand Up @@ -263,10 +267,9 @@ class KeyBindMenu extends FlxSubState

if (KeyBinds.gamepad)
{
for (i in 0...4)
for (i in 0...6)
{
var textStart = (i == curSelected) ? "> " : " ";
trace(gpKeys[i]);
keyTextDisplay.text += textStart + keyText[i] + ": " + gpKeys[i] + "\n";
}
}
Expand All @@ -277,6 +280,19 @@ class KeyBindMenu extends FlxSubState
var textStart = (i == curSelected) ? "> " : " ";
keyTextDisplay.text += textStart + keyText[i] + ": " + ((keys[i] != keyText[i]) ? (keys[i] + " / ") : "") + keyText[i] + " ARROW\n";
}
var textStartPause = (4 == curSelected) ? "> " : " ";
keyTextDisplay.text += textStartPause + keyText[4] + ": " + (keys[4]) + "\n";

var textStartReset = (5 == curSelected) ? "> " : " ";
keyTextDisplay.text += textStartReset + keyText[5] + ": " + (keys[5]) + "\n";

for (i in 6...9)
{
var textStart = (i == curSelected) ? "> " : " ";
keyTextDisplay.text += textStart + keyText[i] + ": " + keys[i] + "\n";
}
var textStartReset = (9 == curSelected) ? "> " : " ";
keyTextDisplay.text += textStartReset + keyText[9] + ": " + (keys[9]) + "\n";
}

keyTextDisplay.screenCenter();
Expand All @@ -288,11 +304,24 @@ class KeyBindMenu extends FlxSubState
FlxG.save.data.downBind = keys[1];
FlxG.save.data.leftBind = keys[0];
FlxG.save.data.rightBind = keys[3];
FlxG.save.data.pauseBind = keys[4];
FlxG.save.data.resetBind = keys[5];

FlxG.save.data.gpupBind = gpKeys[2];
FlxG.save.data.gpdownBind = gpKeys[1];
FlxG.save.data.gpleftBind = gpKeys[0];
FlxG.save.data.gprightBind = gpKeys[3];
FlxG.save.data.gppauseBind = gpKeys[4];
FlxG.save.data.gpresetBind = gpKeys[5];

FlxG.save.data.muteBind = keys[6];
FlxG.save.data.volUpBind = keys[7];
FlxG.save.data.volDownBind = keys[8];
FlxG.save.data.fullscreenBind = keys[9];

FlxG.sound.muteKeys = [FlxKey.fromString(keys[6])];
FlxG.sound.volumeDownKeys = [FlxKey.fromString(keys[8])];
FlxG.sound.volumeUpKeys = [FlxKey.fromString(keys[7])];

FlxG.save.flush();

Expand Down Expand Up @@ -435,9 +464,9 @@ class KeyBindMenu extends FlxSubState
{
curSelected += _amount;

if (curSelected > 3)
if (curSelected > 9)
curSelected = 0;
if (curSelected < 0)
curSelected = 3;
curSelected = 9;
}
}
59 changes: 55 additions & 4 deletions source/KeyBinds.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,26 @@ class KeyBinds
FlxG.save.data.downBind = "S";
FlxG.save.data.leftBind = "A";
FlxG.save.data.rightBind = "D";
FlxG.save.data.killBind = "R";
FlxG.save.data.muteBind = "NUMPADZERO";
FlxG.save.data.volUpBind = "NUMPADPLUS";
FlxG.save.data.volDownBind = "NUMPADMINUS";
FlxG.save.data.fullscreenBind = "F";
FlxG.save.data.gpupBind = "DPAD_UP";
FlxG.save.data.gpdownBind = "DPAD_DOWN";
FlxG.save.data.gpleftBind = "DPAD_LEFT";
FlxG.save.data.gprightBind = "DPAD_RIGHT";
FlxG.save.data.pauseBind = "ENTER";
FlxG.save.data.gppauseBind = "START";
FlxG.save.data.resetBind = "R";
FlxG.save.data.gpresetBind = "SELECT";
FlxG.save.data.muteBind = "NUMPADZERO";
FlxG.save.data.volDownBind = "NUMPADMINUS";
FlxG.save.data.volUpBind = "NUMPADPLUS";
FlxG.save.data.fullscreenBind = "F";

FlxG.sound.muteKeys = ["ZERO", "NUMPADZERO"];
FlxG.sound.volumeDownKeys = ["MINUS", "NUMPADMINUS"];
FlxG.sound.volumeUpKeys = ["PLUS", "NUMPADPLUS"];
PlayerSettings.player1.controls.loadKeyBinds();
}

Expand Down Expand Up @@ -70,10 +85,46 @@ class KeyBinds
FlxG.save.data.gprightBind = "DPAD_RIGHT";
trace("No GRIGHT");
}
if (FlxG.save.data.killBind == null)
if (FlxG.save.data.pauseBind == null)
{
FlxG.save.data.pauseBind = "ENTER";
trace("No ENTER");
}
if (FlxG.save.data.gppauseBind == null)
{
FlxG.save.data.gppauseBind = "START";
trace("No ENTER");
}
if (FlxG.save.data.resetBind == null)
{
FlxG.save.data.resetBind = "R";
trace("No RESET");
}
if (FlxG.save.data.gpresetBind == null)
{
FlxG.save.data.gpresetBind = "SELECT";
trace("No RESET");
}
// VOLUME CONTROLS !!!!
if (FlxG.save.data.muteBind == null)
{
FlxG.save.data.muteBind = "NUMPADZERO";
trace("No MUTE");
}
if (FlxG.save.data.volUpBind == null)
{
FlxG.save.data.volUpBind = "NUMPADPLUS";
trace("No VOLUP");
}
if (FlxG.save.data.volDownBind == null)
{
FlxG.save.data.volDownBind = "NUMPADMINUS";
trace("No VOLDOWN");
}
if (FlxG.save.data.fullscreenBind == null)
{
FlxG.save.data.killBind = "R";
trace("No KILL");
FlxG.save.data.fullscreenBind = "F";
trace("No FULLSCREEN");
}

trace('${FlxG.save.data.leftBind}-${FlxG.save.data.downBind}-${FlxG.save.data.upBind}-${FlxG.save.data.rightBind}');
Expand Down
41 changes: 24 additions & 17 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -719,25 +719,22 @@ class PlayState extends MusicBeatState
if (PlayStateChangeables.useDownscroll)
strumLine.y = FlxG.height - 165;

laneunderlayOpponent = new FlxSprite(0, 0).makeGraphic(500, FlxG.height * 2);
laneunderlayOpponent.x += 95;
laneunderlayOpponent.x += ((FlxG.width / 2) * 0);
laneunderlayOpponent = new FlxSprite(0, 0).makeGraphic(110 * 4 + 50, FlxG.height * 2);
laneunderlayOpponent.alpha = 1 - FlxG.save.data.laneTransparency;
laneunderlayOpponent.color = FlxColor.BLACK;
laneunderlayOpponent.scrollFactor.set();
laneunderlayOpponent.screenCenter(Y);

laneunderlay = new FlxSprite(0, 0).makeGraphic(500, FlxG.height * 2);
laneunderlay.x += 75;
laneunderlay.x += ((FlxG.width / 2) * 1);
laneunderlay = new FlxSprite(0, 0).makeGraphic(110 * 4 + 50, FlxG.height * 2);
laneunderlay.alpha = 1 - FlxG.save.data.laneTransparency;
laneunderlay.color = FlxColor.BLACK;
laneunderlay.scrollFactor.set();
laneunderlay.screenCenter(Y);

if (FlxG.save.data.laneUnderlay && !PlayStateChangeables.Optimize)
{
add(laneunderlayOpponent);
if (!FlxG.save.data.middleScroll)
{
add(laneunderlayOpponent);
}
add(laneunderlay);
}

Expand All @@ -750,11 +747,13 @@ class PlayState extends MusicBeatState
generateStaticArrows(0);
generateStaticArrows(1);

if (FlxG.save.data.middleScroll)
{
laneunderlayOpponent.alpha = 0;
laneunderlay.x = playerStrums.members[0].x - 25;
}
// Update lane underlay positions AFTER static arrows :)

laneunderlay.x = playerStrums.members[0].x - 25;
laneunderlayOpponent.x = cpuStrums.members[0].x - 25;

laneunderlay.screenCenter(Y);
laneunderlayOpponent.screenCenter(Y);

// startCountdown();

Expand Down Expand Up @@ -1587,7 +1586,7 @@ class PlayState extends MusicBeatState
{
songPosBG = new FlxSprite(0, 10).loadGraphic(Paths.loadImage('healthBar'));
if (PlayStateChangeables.useDownscroll)
songPosBG.y = FlxG.height * 0.9 + 45;
songPosBG.y = FlxG.height * 0.9 + 35;
songPosBG.screenCenter(X);
songPosBG.scrollFactor.set();

Expand Down Expand Up @@ -2227,7 +2226,13 @@ class PlayState extends MusicBeatState

scoreTxt.screenCenter(X);

if (controls.PAUSE && startedCountdown && canPause && !cannotDie)
var pauseBind = FlxKey.fromString(FlxG.save.data.pauseBind);
var gppauseBind = FlxKey.fromString(FlxG.save.data.gppauseBind);

if ((FlxG.keys.anyJustPressed([pauseBind]) || KeyBinds.gamepad && FlxG.keys.anyJustPressed([gppauseBind]))
&& startedCountdown
&& canPause
&& !cannotDie)
{
persistentUpdate = false;
persistentDraw = true;
Expand Down Expand Up @@ -2790,7 +2795,9 @@ class PlayState extends MusicBeatState
}
if (!inCutscene && FlxG.save.data.resetButton)
{
if (FlxG.keys.justPressed.R)
var resetBind = FlxKey.fromString(FlxG.save.data.resetBind);
var gpresetBind = FlxKey.fromString(FlxG.save.data.gpresetBind);
if ((FlxG.keys.anyJustPressed([resetBind]) || KeyBinds.gamepad && FlxG.keys.anyJustPressed([gpresetBind])))
{
boyfriend.stunned = true;

Expand Down
4 changes: 3 additions & 1 deletion source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import lime.app.Application;
import openfl.Assets;
import flixel.input.keyboard.FlxKey;
#if FEATURE_DISCORD
import Discord.DiscordClient;
#end
Expand Down Expand Up @@ -227,13 +228,14 @@ class TitleState extends MusicBeatState
}

var transitioning:Bool = false;
var fullscreenBind = FlxKey.fromString(FlxG.save.data.fullscreenBind);

override function update(elapsed:Float)
{
if (FlxG.sound.music != null)
Conductor.songPosition = FlxG.sound.music.time;

if (FlxG.keys.justPressed.F)
if (FlxG.keys.anyJustPressed([fullscreenBind]))
{
FlxG.fullscreen = !FlxG.fullscreen;
}
Expand Down

0 comments on commit b8fe0a2

Please sign in to comment.