diff --git a/source/Controls.hx b/source/Controls.hx index ac44eed..b52b858 100644 --- a/source/Controls.hx +++ b/source/Controls.hx @@ -1,5 +1,6 @@ package; +import flixel.input.gamepad.FlxGamepad; import flixel.FlxG; import flixel.input.FlxInput; import flixel.input.actions.FlxAction; @@ -571,8 +572,22 @@ class Controls extends FlxActionSet //trace(FlxKey.fromString(FlxG.save.data.upBind)); removeKeyboard(); + if (gamepadsAdded.length != 0) + removeGamepad(); KeyBinds.keyCheck(); - + + var buttons = new Map>(); + + buttons.set(Control.UP,[FlxGamepadInputID.fromString(FlxG.save.data.gpupBind)]); + buttons.set(Control.LEFT,[FlxGamepadInputID.fromString(FlxG.save.data.gpleftBind)]); + buttons.set(Control.DOWN,[FlxGamepadInputID.fromString(FlxG.save.data.gpdownBind)]); + 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]); + + addGamepad(0,buttons); + inline bindKeys(Control.UP, [FlxKey.fromString(FlxG.save.data.upBind), FlxKey.UP]); inline bindKeys(Control.DOWN, [FlxKey.fromString(FlxG.save.data.downBind), FlxKey.DOWN]); inline bindKeys(Control.LEFT, [FlxKey.fromString(FlxG.save.data.leftBind), FlxKey.LEFT]); @@ -599,6 +614,9 @@ class Controls extends FlxActionSet public function addGamepad(id:Int, ?buttonMap:Map>):Void { + if (gamepadsAdded.contains(id)) + gamepadsAdded.remove(id); + gamepadsAdded.push(id); #if (haxe >= "4.0.0") diff --git a/source/DialogueBox.hx b/source/DialogueBox.hx index 929eb24..d52358c 100644 --- a/source/DialogueBox.hx +++ b/source/DialogueBox.hx @@ -177,7 +177,7 @@ class DialogueBox extends FlxSpriteGroup dialogueStarted = true; } - if (FlxG.keys.justPressed.ANY && dialogueStarted == true) + if (PlayerSettings.player1.controls.ACCEPT && dialogueStarted == true) { remove(dialogue); diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index daf04fb..243d970 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -1,5 +1,6 @@ package; +import flixel.input.gamepad.FlxGamepad; import flash.text.TextField; import flixel.FlxG; import flixel.FlxSprite; @@ -184,10 +185,32 @@ class FreeplayState extends MusicBeatState scoreText.text = "PERSONAL BEST:" + lerpScore; comboText.text = combo + '\n'; - var upP = controls.UP_P; - var downP = controls.DOWN_P; + var upP = FlxG.keys.justPressed.UP; + var downP = FlxG.keys.justPressed.DOWN; var accepted = controls.ACCEPT; + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + + if (gamepad != null) + { + if (gamepad.justPressed.DPAD_UP) + { + changeSelection(-1); + } + if (gamepad.justPressed.DPAD_DOWN) + { + changeSelection(1); + } + if (gamepad.justPressed.DPAD_LEFT) + { + changeDiff(-1); + } + if (gamepad.justPressed.DPAD_RIGHT) + { + changeDiff(1); + } + } + if (upP) { changeSelection(-1); @@ -197,9 +220,9 @@ class FreeplayState extends MusicBeatState changeSelection(1); } - if (controls.LEFT_P) + if (FlxG.keys.justPressed.LEFT) changeDiff(-1); - if (controls.RIGHT_P) + if (FlxG.keys.justPressed.RIGHT) changeDiff(1); if (controls.BACK) diff --git a/source/KadeEngineData.hx b/source/KadeEngineData.hx index 764ecf8..0a26829 100644 --- a/source/KadeEngineData.hx +++ b/source/KadeEngineData.hx @@ -1,3 +1,4 @@ +import flixel.input.gamepad.FlxGamepad; import openfl.Lib; import flixel.FlxG; @@ -92,6 +93,10 @@ class KadeEngineData if (FlxG.save.data.optimize == null) FlxG.save.data.optimize = false; + + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + + KeyBinds.gamepad = gamepad != null; Conductor.recalculateTimings(); PlayerSettings.player1.controls.loadKeyBinds(); diff --git a/source/KeyBindMenu.hx b/source/KeyBindMenu.hx index fd6cb85..d5a3d41 100644 --- a/source/KeyBindMenu.hx +++ b/source/KeyBindMenu.hx @@ -3,6 +3,7 @@ package; /// Code created by Rozebud for FPS Plus (thanks rozebud) // modified by KadeDev for use in Kade Engine/Tricky +import flixel.input.gamepad.FlxGamepad; import flixel.util.FlxAxes; import flixel.FlxSubState; import Options.Option; @@ -36,15 +37,19 @@ class KeyBindMenu extends FlxSubState var warningTween:FlxTween; var keyText:Array = ["LEFT", "DOWN", "UP", "RIGHT"]; var defaultKeys:Array = ["A", "S", "W", "D", "R"]; + var defaultGpKeys:Array = ["DPAD_LEFT", "DPAD_DOWN", "DPAD_UP", "DPAD_RIGHT"]; var curSelected:Int = 0; var keys:Array = [FlxG.save.data.leftBind, FlxG.save.data.downBind, FlxG.save.data.upBind, FlxG.save.data.rightBind]; - + var gpKeys:Array = [FlxG.save.data.gpleftBind, + FlxG.save.data.gpdownBind, + FlxG.save.data.gpupBind, + FlxG.save.data.gprightBind]; var tempKey:String = ""; - var blacklist:Array = ["ESCAPE", "ENTER", "BACKSPACE", "SPACE"]; + var blacklist:Array = ["ESCAPE", "ENTER", "BACKSPACE", "SPACE", "TAB"]; var blackBox:FlxSprite; var infoText:FlxText; @@ -60,10 +65,17 @@ class KeyBindMenu extends FlxSubState if (k == null) keys[i] = defaultKeys[i]; } + + for (i in 0...gpKeys.length) + { + var k = gpKeys[i]; + if (k == null) + gpKeys[i] = defaultGpKeys[i]; + } //FlxG.sound.playMusic('assets/music/configurator' + TitleState.soundExt); - persistentUpdate = persistentDraw = true; + persistentUpdate = true; keyTextDisplay = new FlxText(-10, 0, 1280, "", 72); keyTextDisplay.scrollFactor.set(0, 0); @@ -74,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, "(Escape to save, backspace to leave without saving)", 72); + infoText = new FlxText(-10, 580, 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); infoText.setFormat("VCR OSD Mono", 24, FlxColor.WHITE, FlxTextAlign.CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); infoText.borderSize = 2; @@ -98,23 +110,36 @@ class KeyBindMenu extends FlxSubState super.create(); } + var frames = 0; + override function update(elapsed:Float) { + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + + if (frames <= 10) + frames++; switch(state){ case "select": if (FlxG.keys.justPressed.UP) - { - FlxG.sound.play(Paths.sound('scrollMenu')); - changeItem(-1); - } + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeItem(-1); + } - if (FlxG.keys.justPressed.DOWN) - { - FlxG.sound.play(Paths.sound('scrollMenu')); - changeItem(1); - } + if (FlxG.keys.justPressed.DOWN) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeItem(1); + } + + if (FlxG.keys.justPressed.TAB) + { + KeyBinds.gamepad = !KeyBinds.gamepad; + infoText.text = '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' : ''})'; + textUpdate(); + } if (FlxG.keys.justPressed.ENTER){ FlxG.sound.play(Paths.sound('scrollMenu')); @@ -123,31 +148,87 @@ class KeyBindMenu extends FlxSubState else if(FlxG.keys.justPressed.ESCAPE){ quit(); } - else if (FlxG.keys.justPressed.BACKSPACE){ + else if (FlxG.keys.justPressed.BACKSPACE){ reset(); } + if (gamepad != null) // GP Logic + { + if (gamepad.justPressed.DPAD_UP) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeItem(-1); + textUpdate(); + } + if (gamepad.justPressed.DPAD_DOWN) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeItem(1); + textUpdate(); + } + + if (gamepad.justPressed.START && frames > 10){ + FlxG.sound.play(Paths.sound('scrollMenu')); + state = "input"; + } + else if(gamepad.justPressed.LEFT_TRIGGER){ + quit(); + } + else if (gamepad.justPressed.RIGHT_TRIGGER){ + reset(); + } + } case "input": tempKey = keys[curSelected]; keys[curSelected] = "?"; + if (KeyBinds.gamepad) + gpKeys[curSelected] = "?"; textUpdate(); state = "waiting"; case "waiting": - if(FlxG.keys.justPressed.ESCAPE){ - keys[curSelected] = tempKey; - state = "select"; - FlxG.sound.play(Paths.sound('confirmMenu')); + if (gamepad != null && KeyBinds.gamepad) // GP Logic + { + if(FlxG.keys.justPressed.ESCAPE){ // just in case you get stuck + gpKeys[curSelected] = tempKey; + state = "select"; + FlxG.sound.play(Paths.sound('confirmMenu')); + } + + if (gamepad.justPressed.START) + { + addKeyGamepad(defaultKeys[curSelected]); + save(); + state = "select"; + } + + if (gamepad.justPressed.ANY) + { + trace(gamepad.firstJustPressedID()); + addKeyGamepad(gamepad.firstJustPressedID()); + save(); + state = "select"; + textUpdate(); + } + } - else if(FlxG.keys.justPressed.ENTER){ - addKey(defaultKeys[curSelected]); - save(); - state = "select"; - } - else if(FlxG.keys.justPressed.ANY){ - addKey(FlxG.keys.getIsDown()[0].ID.toString()); - save(); - state = "select"; + else + { + if(FlxG.keys.justPressed.ESCAPE){ + keys[curSelected] = tempKey; + state = "select"; + FlxG.sound.play(Paths.sound('confirmMenu')); + } + else if(FlxG.keys.justPressed.ENTER){ + addKey(defaultKeys[curSelected]); + save(); + state = "select"; + } + else if(FlxG.keys.justPressed.ANY){ + addKey(FlxG.keys.getIsDown()[0].ID.toString()); + save(); + state = "select"; + } } @@ -170,11 +251,24 @@ class KeyBindMenu extends FlxSubState keyTextDisplay.text = "\n\n"; - for(i in 0...4){ + if (KeyBinds.gamepad) + { + for(i in 0...4){ - var textStart = (i == curSelected) ? "> " : " "; - keyTextDisplay.text += textStart + keyText[i] + ": " + ((keys[i] != keyText[i]) ? (keys[i] + " / ") : "" ) + keyText[i] + " ARROW\n"; + var textStart = (i == curSelected) ? "> " : " "; + trace(gpKeys[i]); + keyTextDisplay.text += textStart + keyText[i] + ": " + gpKeys[i] + "\n"; + + } + } + else + { + for(i in 0...4){ + var textStart = (i == curSelected) ? "> " : " "; + keyTextDisplay.text += textStart + keyText[i] + ": " + ((keys[i] != keyText[i]) ? (keys[i] + " / ") : "" ) + keyText[i] + " ARROW\n"; + + } } keyTextDisplay.screenCenter(); @@ -187,6 +281,11 @@ 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.gpupBind = gpKeys[2]; + FlxG.save.data.gpdownBind = gpKeys[1]; + FlxG.save.data.gpleftBind = gpKeys[0]; + FlxG.save.data.gprightBind = gpKeys[3]; FlxG.save.flush(); @@ -217,6 +316,38 @@ class KeyBindMenu extends FlxSubState } + function addKeyGamepad(r:String){ + + var shouldReturn:Bool = true; + + var notAllowed:Array = ["START", "RIGHT_TRIGGER", "LEFT_TRIGGER"]; + + for(x in 0...gpKeys.length) + { + var oK = gpKeys[x]; + if(oK == r) + gpKeys[x] = null; + if (notAllowed.contains(oK)) + { + gpKeys[x] = null; + return; + } + } + + if(shouldReturn){ + gpKeys[curSelected] = r; + FlxG.sound.play(Paths.sound('scrollMenu')); + } + else{ + gpKeys[curSelected] = tempKey; + FlxG.sound.play(Paths.sound('scrollMenu')); + keyWarning.alpha = 1; + warningTween.cancel(); + warningTween = FlxTween.tween(keyWarning, {alpha: 0}, 0.5, {ease: FlxEase.circOut, startDelay: 2}); + } + + } + function addKey(r:String){ var shouldReturn:Bool = true; @@ -233,7 +364,10 @@ class KeyBindMenu extends FlxSubState if(oK == r) keys[x] = null; if (notAllowed.contains(oK)) + { + keys[x] = null; return; + } } if (r.contains("NUMPAD")) diff --git a/source/KeyBinds.hx b/source/KeyBinds.hx index 2844118..2514ea1 100644 --- a/source/KeyBinds.hx +++ b/source/KeyBinds.hx @@ -12,6 +12,8 @@ import flixel.input.keyboard.FlxKey; class KeyBinds { + public static var gamepad:Bool = false; + public static function resetBinds():Void{ FlxG.save.data.upBind = "W"; @@ -19,6 +21,10 @@ class KeyBinds FlxG.save.data.leftBind = "A"; FlxG.save.data.rightBind = "D"; FlxG.save.data.killBind = "R"; + FlxG.save.data.gpupBind = "DPAD_UP"; + FlxG.save.data.gpdownBind = "DPAD_DOWN"; + FlxG.save.data.gpleftBind = "DPAD_LEFT"; + FlxG.save.data.gprightBind = "DPAD_RIGHT"; PlayerSettings.player1.controls.loadKeyBinds(); } @@ -49,9 +55,22 @@ class KeyBinds } if (StringTools.contains(FlxG.save.data.rightBind,"NUMPAD")) FlxG.save.data.rightBind = "D"; - if(FlxG.save.data.killBind == null){ - FlxG.save.data.killBind = "R"; - trace("No KILL"); + + if(FlxG.save.data.gpupBind == null){ + FlxG.save.data.gpupBind = "DPAD_UP"; + trace("No GUP"); + } + if(FlxG.save.data.gpdownBind == null){ + FlxG.save.data.gpdownBind = "DPAD_DOWN"; + trace("No GDOWN"); + } + if(FlxG.save.data.gpleftBind == null){ + FlxG.save.data.gpleftBind = "DPAD_LEFT"; + trace("No GLEFT"); + } + if(FlxG.save.data.gprightBind == null){ + FlxG.save.data.gprightBind = "DPAD_RIGHT"; + trace("No GRIGHT"); } trace('${FlxG.save.data.leftBind}-${FlxG.save.data.downBind}-${FlxG.save.data.upBind}-${FlxG.save.data.rightBind}'); diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index f2c5d67..18933f5 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -1,5 +1,6 @@ package; +import flixel.input.gamepad.FlxGamepad; import Controls.KeyboardScheme; import flixel.FlxG; import flixel.FlxObject; @@ -144,13 +145,29 @@ class MainMenuState extends MusicBeatState if (!selectedSomethin) { - if (controls.UP_P) + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + + if (gamepad != null) + { + if (gamepad.justPressed.DPAD_UP) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeItem(-1); + } + if (gamepad.justPressed.DPAD_DOWN) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeItem(1); + } + } + + if (FlxG.keys.justPressed.UP) { FlxG.sound.play(Paths.sound('scrollMenu')); changeItem(-1); } - if (controls.DOWN_P) + if (FlxG.keys.justPressed.DOWN) { FlxG.sound.play(Paths.sound('scrollMenu')); changeItem(1); diff --git a/source/Options.hx b/source/Options.hx index c7ef026..7c8f411 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -317,10 +317,10 @@ class Judgement extends Option override function getValue():String { return "Safe Frames: " + Conductor.safeFrames + - " - SIK: " + HelperFunctions.truncateFloat(22 * Conductor.timeScale, 0) + - "ms GD: " + HelperFunctions.truncateFloat(45 * Conductor.timeScale, 0) + + " - SIK: " + HelperFunctions.truncateFloat(45 * Conductor.timeScale, 0) + + "ms GD: " + HelperFunctions.truncateFloat(90 * Conductor.timeScale, 0) + "ms BD: " + HelperFunctions.truncateFloat(135 * Conductor.timeScale, 0) + - "ms SHT: " + HelperFunctions.truncateFloat(155 * Conductor.timeScale, 0) + + "ms SHT: " + HelperFunctions.truncateFloat(166 * Conductor.timeScale, 0) + "ms TOTAL: " + HelperFunctions.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; } diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 9a89d12..6581771 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -1,5 +1,6 @@ package; +import flixel.input.gamepad.FlxGamepad; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import openfl.Lib; @@ -144,9 +145,26 @@ class OptionsMenu extends MusicBeatState changeSelection(curSelected); } - if (controls.UP_P) + + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + + if (gamepad != null) + { + if (gamepad.justPressed.DPAD_UP) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeSelection(-1); + } + if (gamepad.justPressed.DPAD_DOWN) + { + FlxG.sound.play(Paths.sound('scrollMenu')); + changeSelection(1); + } + } + + if (FlxG.keys.justPressed.UP) changeSelection(-1); - if (controls.DOWN_P) + if (FlxG.keys.justPressed.DOWN) changeSelection(1); if (isCat) diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index 3985d4b..8d0c323 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -1,5 +1,6 @@ package; +import flixel.input.gamepad.FlxGamepad; import openfl.Lib; #if windows import llua.Lua; @@ -108,6 +109,8 @@ class PauseSubState extends MusicBeatSubstate if (PlayState.instance.useVideo) menuItems.remove('Resume'); + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + var upP = controls.UP_P; var downP = controls.DOWN_P; var leftP = controls.LEFT_P; @@ -115,6 +118,14 @@ class PauseSubState extends MusicBeatSubstate var accepted = controls.ACCEPT; var oldOffset:Float = 0; + if (gamepad != null && KeyBinds.gamepad) + { + upP = gamepad.justPressed.DPAD_UP; + downP = gamepad.justPressed.DPAD_DOWN; + leftP = gamepad.justPressed.DPAD_LEFT; + rightP = gamepad.justPressed.DPAD_RIGHT; + } + // pre lowercasing the song name (update) var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); switch (songLowercase) { diff --git a/source/PlayState.hx b/source/PlayState.hx index f53a55e..738b7bc 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1,5 +1,6 @@ package; +import openfl.ui.KeyLocation; import openfl.events.Event; import haxe.EnumTools; import openfl.ui.Keyboard; @@ -998,11 +999,7 @@ class PlayState extends MusicBeatState add(healthBar); // Add Kade Engine watermark -<<<<<<< HEAD - kadeEngineWatermark = new FlxText(4,healthBarBG.y + 50,0,SONG.song + " " + CoolUtil.difficultyFromInt(storyDifficulty) + (Main.watermarks ? " - KE " + MainMenuState.kadeEngineVer : ""), 16); -======= kadeEngineWatermark = new FlxText(4,healthBarBG.y + 50,0,SONG.song + " - " + CoolUtil.difficultyFromInt(storyDifficulty) + (Main.watermarks ? " | KE " + MainMenuState.kadeEngineVer : ""), 16); ->>>>>>> origin/master kadeEngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK); kadeEngineWatermark.scrollFactor.set(); add(kadeEngineWatermark); @@ -1403,6 +1400,10 @@ class PlayState extends MusicBeatState data = i; } + if (evt.keyLocation == KeyLocation.NUM_PAD) + { + trace(String.fromCharCode(evt.charCode) + " " + key); + } if (data == -1) return; @@ -3118,7 +3119,7 @@ class PlayState extends MusicBeatState var rightHold:Bool = false; var leftHold:Bool = false; - // THIS FUNCTION JUST FUCKS WIT HELD NOTES AND BOTPLAY/REPLAY + // THIS FUNCTION JUST FUCKS WIT HELD NOTES AND BOTPLAY/REPLAY (also gamepad shit) private function keyShit():Void // I've invested in emma stocks { @@ -3144,10 +3145,7 @@ class PlayState extends MusicBeatState if (controls.RIGHT_P){luaModchart.executeState('keyPressed',["right"]);}; }; #end -<<<<<<< HEAD -======= ->>>>>>> origin/master // Prevent player input if botplay is on if(PlayStateChangeables.botPlay) @@ -3159,15 +3157,9 @@ class PlayState extends MusicBeatState var anas:Array = [null,null,null,null]; -<<<<<<< HEAD for (i in 0...pressArray.length) if (pressArray[i]) anas[i] = new Ana(Conductor.songPosition, null, false, "miss", i); -======= - /*for (i in 0...pressArray.length) - if (pressArray[i]) - anas[i] = new Ana(Conductor.songPosition, null, false, "miss", i);*/ ->>>>>>> origin/master // HOLDS, check for sustain notes if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic) @@ -3179,118 +3171,80 @@ class PlayState extends MusicBeatState }); } - // PRESSES, check for note hits - /*if (pressArray.contains(true) && generatedMusic) + if (KeyBinds.gamepad && !FlxG.keys.justPressed.ANY) { - boyfriend.holdTimer = 0; - - var possibleNotes:Array = []; // notes that can be hit - var directionList:Array = []; // directions that can be hit - var dumbNotes:Array = []; // notes to kill later - var directionsAccounted:Array = [false,false,false,false]; // we don't want to do judgments for more than one presses - - notes.forEachAlive(function(daNote:Note) + // PRESSES, check for note hits + if (pressArray.contains(true) && generatedMusic) { - if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit) + boyfriend.holdTimer = 0; + + var possibleNotes:Array = []; // notes that can be hit + var directionList:Array = []; // directions that can be hit + var dumbNotes:Array = []; // notes to kill later + var directionsAccounted:Array = [false,false,false,false]; // we don't want to do judgments for more than one presses + + notes.forEachAlive(function(daNote:Note) { - if (!directionsAccounted[daNote.noteData]) + if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit) { -<<<<<<< HEAD - directionsAccounted[daNote.noteData] = true; - possibleNotes.push(daNote); - directionList.push(daNote.noteData); -======= - if (directionList.contains(daNote.noteData)) - { - directionsAccounted[daNote.noteData] = true; - for (coolNote in possibleNotes) - { - if (coolNote.noteData == daNote.noteData && Math.abs(daNote.strumTime - coolNote.strumTime) < 10) - { // if it's the same note twice at < 10ms distance, just delete it - // EXCEPT u cant delete it in this loop cuz it fucks with the collection lol - dumbNotes.push(daNote); - break; - } - else if (coolNote.noteData == daNote.noteData && daNote.strumTime < coolNote.strumTime) - { // if daNote is earlier than existing note (coolNote), replace - possibleNotes.remove(coolNote); - possibleNotes.push(daNote); - break; - } - } - } - else - { - possibleNotes.push(daNote); - directionList.push(daNote.noteData); - } ->>>>>>> origin/master - } - } - }); - - trace('notes that can be hit: ' + possibleNotes.length); - - for (note in dumbNotes) - { - FlxG.log.add("killing dumb ass note at " + note.strumTime); - note.kill(); - notes.remove(note, true); - note.destroy(); - } - - possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); - - if (perfectMode) - goodNoteHit(possibleNotes[0]); - else if (possibleNotes.length > 0) - { - if (!FlxG.save.data.ghost) - { - for (shit in 0...pressArray.length) - { // if a direction is hit that shouldn't be - if (pressArray[shit] && !directionList.contains(shit)) - noteMiss(shit, null); + if (!directionsAccounted[daNote.noteData]) + { + directionsAccounted[daNote.noteData] = true; + possibleNotes.push(daNote); + directionList.push(daNote.noteData); } - } - for (coolNote in possibleNotes) + } + }); + trace('notes that can be hit: ' + possibleNotes.length); + for (note in dumbNotes) { - if (pressArray[coolNote.noteData]) + FlxG.log.add("killing dumb ass note at " + note.strumTime); + note.kill(); + notes.remove(note, true); + note.destroy(); + } + + possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); + if (perfectMode) + goodNoteHit(possibleNotes[0]); + else if (possibleNotes.length > 0) + { + if (!FlxG.save.data.ghost) { - if (mashViolations != 0) - mashViolations--; - scoreTxt.color = FlxColor.WHITE; - var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition); - anas[coolNote.noteData].hit = true; - anas[coolNote.noteData].hitJudge = Ratings.CalculateRating(noteDiff, Math.floor((PlayStateChangeables.safeFrames / 60) * 1000)); - anas[coolNote.noteData].nearestNote = [coolNote.strumTime,coolNote.noteData,coolNote.sustainLength]; - goodNoteHit(coolNote); + for (shit in 0...pressArray.length) + { // if a direction is hit that shouldn't be + if (pressArray[shit] && !directionList.contains(shit)) + noteMiss(shit, null); + } + } + for (coolNote in possibleNotes) + { + if (pressArray[coolNote.noteData]) + { + if (mashViolations != 0) + mashViolations--; + scoreTxt.color = FlxColor.WHITE; + var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition); + anas[coolNote.noteData].hit = true; + anas[coolNote.noteData].hitJudge = Ratings.CalculateRating(noteDiff, Math.floor((PlayStateChangeables.safeFrames / 60) * 1000)); + anas[coolNote.noteData].nearestNote = [coolNote.strumTime,coolNote.noteData,coolNote.sustainLength]; + goodNoteHit(coolNote); + } } } + else if (!FlxG.save.data.ghost) + { + for (shit in 0...pressArray.length) + if (pressArray[shit]) + noteMiss(shit, null); + } } - else if (!FlxG.save.data.ghost) - { - for (shit in 0...pressArray.length) - if (pressArray[shit]) - noteMiss(shit, null); - } -<<<<<<< HEAD + if (!loadRep) + for (i in anas) + if (i != null) + replayAna.anaArray.push(i); // put em all there } - - if (!loadRep) - for (i in anas) - if (i != null) - replayAna.anaArray.push(i); // put em all there -======= - }*/ - - /*if (!loadRep) - for (i in anas) - if (i != null) - replayAna.anaArray.push(i); // put em all there*/ ->>>>>>> origin/master - notes.forEachAlive(function(daNote:Note) { if(PlayStateChangeables.useDownscroll && daNote.y > strumLine.y || diff --git a/source/ResultsScreen.hx b/source/ResultsScreen.hx index 1343b04..255ab8c 100644 --- a/source/ResultsScreen.hx +++ b/source/ResultsScreen.hx @@ -82,7 +82,7 @@ class ResultsScreen extends FlxSubState comboText.scrollFactor.set(); add(comboText); - contText = new FlxText(FlxG.width - 475,FlxG.height + 50,0,'Press ENTER to continue.'); + contText = new FlxText(FlxG.width - 475,FlxG.height + 50,0,'Press ${KeyBinds.gamepad ? 'A' : 'ENTER'} to continue.'); contText.size = 28; contText.setBorderStyle(FlxTextBorderStyle.OUTLINE,FlxColor.BLACK,4,1); contText.color = FlxColor.WHITE; @@ -172,7 +172,7 @@ class ResultsScreen extends FlxSubState // keybinds - if (FlxG.keys.justPressed.ENTER) + if (PlayerSettings.player1.controls.ACCEPT) { music.fadeOut(0.3); @@ -199,12 +199,6 @@ class ResultsScreen extends FlxSubState FlxG.switchState(new FreeplayState()); } - if (FlxG.keys.justPressed.EIGHT) - { - graph.showInput = !graph.showInput; - graph.update(); - } - if (FlxG.keys.justPressed.F1) { trace(PlayState.rep.path); diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index 443b8e0..5957720 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -1,5 +1,6 @@ package; +import flixel.input.gamepad.FlxGamepad; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.transition.FlxTransitionableState; @@ -222,12 +223,44 @@ class StoryMenuState extends MusicBeatState { if (!selectedWeek) { - if (controls.UP_P) + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + + if (gamepad != null) + { + if (gamepad.justPressed.DPAD_UP) + { + changeWeek(-1); + } + if (gamepad.justPressed.DPAD_DOWN) + { + changeWeek(1); + } + + if (gamepad.pressed.DPAD_RIGHT) + rightArrow.animation.play('press') + else + rightArrow.animation.play('idle'); + if (gamepad.pressed.DPAD_LEFT) + leftArrow.animation.play('press'); + else + leftArrow.animation.play('idle'); + + if (gamepad.justPressed.DPAD_RIGHT) + { + changeDifficulty(1); + } + if (gamepad.justPressed.DPAD_LEFT) + { + changeDifficulty(-1); + } + } + + if (FlxG.keys.justPressed.UP) { changeWeek(-1); } - if (controls.DOWN_P) + if (FlxG.keys.justPressed.DOWN) { changeWeek(1); } diff --git a/source/TitleState.hx b/source/TitleState.hx index abcc2d7..4a30c1a 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -80,6 +80,8 @@ class TitleState extends MusicBeatState curWacky = FlxG.random.getObject(getIntroTextShit()); + trace('hello'); + // DEBUG BULLSHIT super.create(); @@ -277,7 +279,7 @@ class TitleState extends MusicBeatState FlxG.fullscreen = !FlxG.fullscreen; } - var pressedEnter:Bool = FlxG.keys.justPressed.ENTER; + var pressedEnter:Bool = controls.ACCEPT; #if mobile for (touch in FlxG.touches.list) @@ -289,19 +291,6 @@ class TitleState extends MusicBeatState } #end - var gamepad:FlxGamepad = FlxG.gamepads.lastActive; - - if (gamepad != null) - { - if (gamepad.justPressed.START) - pressedEnter = true; - - #if switch - if (gamepad.justPressed.B) - pressedEnter = true; - #end - } - if (pressedEnter && !transitioning && skippedIntro) { #if !switch