package; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import openfl.Lib; import Options; import Controls.Control; import flash.text.TextField; import flixel.FlxG; import flixel.FlxSprite; import flixel.addons.display.FlxGridOverlay; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.input.keyboard.FlxKey; import flixel.math.FlxMath; import flixel.text.FlxText; import flixel.util.FlxColor; import lime.utils.Assets; class OptionsMenu extends MusicBeatState { var selector:FlxText; var curSelected:Int = 0; var options:Array = [ new OptionCatagory("Gameplay", [ new DFJKOption(controls), new DownscrollOption("Change the layout of the strumline."), new GhostTapOption("Ghost Tapping is when you tap a direction and it doesn't give you a miss."), new Judgement("Customize your Hit Timings (LEFT or RIGHT)"), #if desktop new FPSCapOption("Cap your FPS"), #end new ScrollSpeedOption("Change your scroll speed (1 = Chart dependent)"), new AccuracyDOption("Change how accuracy is calculated. (Accurate = Simple, Complex = Milisecond Based)"), new ResetButtonOption("Toggle pressing R to gameover."), // new OffsetMenu("Get a note offset based off of your inputs!"), new CustomizeGameplay("Drag'n'Drop Gameplay Modules around to your preference") ]), new OptionCatagory("Appearance", [ #if desktop new DistractionsAndEffectsOption("Toggle stage distractions that can hinder your gameplay."), new RainbowFPSOption("Make the FPS Counter Rainbow"), new AccuracyOption("Display accuracy information."), new NPSDisplayOption("Shows your current Notes Per Second."), new SongPositionOption("Show the songs current position (as a bar)"), new CpuStrums("CPU's strumline lights up when a note hits it."), #else new DistractionsAndEffectsOption("Toggle stage distractions that can hinder your gameplay.") #end ]), new OptionCatagory("Misc", [ #if desktop new FPSOption("Toggle the FPS Counter"), new ReplayOption("View replays"), #end new FlashingLightsOption("Toggle flashing lights that can cause epileptic seizures and strain."), new WatermarkOption("Enable and disable all watermarks from the engine."), new BotPlay("Showcase your charts and mods with autoplay.") ]) ]; private var currentDescription:String = ""; private var grpControls:FlxTypedGroup; public static var versionShit:FlxText; var currentSelectedCat:OptionCatagory; var blackBorder:FlxSprite; override function create() { var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image("menuDesat")); menuBG.color = 0xFFea71fd; menuBG.setGraphicSize(Std.int(menuBG.width * 1.1)); menuBG.updateHitbox(); menuBG.screenCenter(); menuBG.antialiasing = true; add(menuBG); grpControls = new FlxTypedGroup(); add(grpControls); for (i in 0...options.length) { var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, options[i].getName(), true, false, true); controlLabel.isMenuItem = true; controlLabel.targetY = i; grpControls.add(controlLabel); // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! } currentDescription = "none"; versionShit = new FlxText(5, FlxG.height + 40, 0, "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription, 12); versionShit.scrollFactor.set(); versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); blackBorder = new FlxSprite(-30,FlxG.height + 40).makeGraphic((Std.int(versionShit.width + 900)),Std.int(versionShit.height + 600),FlxColor.BLACK); blackBorder.alpha = 0.5; add(blackBorder); add(versionShit); FlxTween.tween(versionShit,{y: FlxG.height - 18},2,{ease: FlxEase.elasticInOut}); FlxTween.tween(blackBorder,{y: FlxG.height - 18},2, {ease: FlxEase.elasticInOut}); super.create(); } var isCat:Bool = false; override function update(elapsed:Float) { super.update(elapsed); if (controls.BACK && !isCat) FlxG.switchState(new MainMenuState()); else if (controls.BACK) { isCat = false; grpControls.clear(); for (i in 0...options.length) { var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, options[i].getName(), true, false); controlLabel.isMenuItem = true; controlLabel.targetY = i; grpControls.add(controlLabel); // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! } curSelected = 0; } if (controls.UP_P) changeSelection(-1); if (controls.DOWN_P) changeSelection(1); if (isCat) { if (currentSelectedCat.getOptions()[curSelected].getAccept()) { if (FlxG.keys.pressed.SHIFT) { if (FlxG.keys.pressed.RIGHT) currentSelectedCat.getOptions()[curSelected].right(); if (FlxG.keys.pressed.LEFT) currentSelectedCat.getOptions()[curSelected].left(); } else { if (FlxG.keys.justPressed.RIGHT) currentSelectedCat.getOptions()[curSelected].right(); if (FlxG.keys.justPressed.LEFT) currentSelectedCat.getOptions()[curSelected].left(); } } else { if (FlxG.keys.pressed.SHIFT) { if (FlxG.keys.justPressed.RIGHT) FlxG.save.data.offset += 0.1; else if (FlxG.keys.justPressed.LEFT) FlxG.save.data.offset -= 0.1; } else if (FlxG.keys.pressed.RIGHT) FlxG.save.data.offset += 0.1; else if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset -= 0.1; } if (currentSelectedCat.getOptions()[curSelected].getAccept()) versionShit.text = currentSelectedCat.getOptions()[curSelected].getValue() + " - Description - " + currentDescription; else versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } else { if (FlxG.keys.pressed.SHIFT) { if (FlxG.keys.justPressed.RIGHT) FlxG.save.data.offset += 0.1; else if (FlxG.keys.justPressed.LEFT) FlxG.save.data.offset -= 0.1; } else if (FlxG.keys.pressed.RIGHT) FlxG.save.data.offset += 0.1; else if (FlxG.keys.pressed.LEFT) FlxG.save.data.offset -= 0.1; } if (controls.RESET) FlxG.save.data.offset = 0; if (controls.ACCEPT) { if (isCat) { if (currentSelectedCat.getOptions()[curSelected].press()) { grpControls.remove(grpControls.members[curSelected]); var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, currentSelectedCat.getOptions()[curSelected].getDisplay(), true, false); ctrl.isMenuItem = true; grpControls.add(ctrl); } } else { currentSelectedCat = options[curSelected]; isCat = true; grpControls.clear(); for (i in 0...currentSelectedCat.getOptions().length) { var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, currentSelectedCat.getOptions()[i].getDisplay(), true, false); controlLabel.isMenuItem = true; controlLabel.targetY = i; grpControls.add(controlLabel); // DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !! } curSelected = 0; } } FlxG.save.flush(); } var isSettingControl:Bool = false; function changeSelection(change:Int = 0) { #if !switch // NGio.logEvent("Fresh"); #end FlxG.sound.play(Paths.sound("scrollMenu"), 0.4); curSelected += change; if (curSelected < 0) curSelected = grpControls.length - 1; if (curSelected >= grpControls.length) curSelected = 0; if (isCat) currentDescription = currentSelectedCat.getOptions()[curSelected].getDescription(); else currentDescription = "Please select a category"; if (isCat) { if (currentSelectedCat.getOptions()[curSelected].getAccept()) versionShit.text = currentSelectedCat.getOptions()[curSelected].getValue() + " - Description - " + currentDescription; else versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; } else versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription; // selector.y = (70 * curSelected) + 30; var bullShit:Int = 0; for (item in grpControls.members) { item.targetY = bullShit - curSelected; bullShit++; item.alpha = 0.6; // item.setGraphicSize(Std.int(item.width * 0.8)); if (item.targetY == 0) { item.alpha = 1; // item.setGraphicSize(Std.int(item.width)); } } } }