diff --git a/README.md b/README.md index 2a18e07..b86198e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ Extra Keys from: https://github.com/Magman03k7/VsDave-ExtraKeysAddon -Need help on polymod coding - ## Dependencies you need to build flixel-addons is 2.11.0 btw diff --git a/source/ModSubState.hx b/source/ModSubState.hx new file mode 100644 index 0000000..f495380 --- /dev/null +++ b/source/ModSubState.hx @@ -0,0 +1,194 @@ +package; + +import flixel.group.FlxGroup; +import haxe.Json; +import haxe.Http; +import flixel.math.FlxRandom; +import Controls.Control; +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.FlxSubState; +import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.system.FlxSound; +import flixel.text.FlxText; +import flixel.tweens.FlxEase; +import flixel.tweens.FlxTween; +import flixel.util.FlxColor; +import flixel.addons.display.FlxBackdrop; +import lime.app.Application; + +class ModSubState extends MusicBeatSubstate +{ + var grpMenuShit:FlxTypedGroup; + var bg:FlxBackdrop; + +// First, create an empty array +var menuItems:Array = []; + + var curSelected:Int = 0; + + var expungedSelectWaitTime:Float = 0; + var timeElapsed:Float = 0; + var patienceTime:Float = 0; + + var funnyTexts:FlxTypedGroup = new FlxTypedGroup(); + public static var inMods:Bool = true; + + public function new(x:Float, y:Float) + { + super(); + +for (i in TitleState.mods) { + menuItems.push(new ModOption(i)); +} + + +menuItems.push(new ModOption('Exit')); + + inMods = true; + + funnyTexts = new FlxTypedGroup(); + add(funnyTexts); + + var backBg:FlxSprite = new FlxSprite(); + backBg.makeGraphic(FlxG.width + 1, FlxG.height + 1, FlxColor.BLACK); + backBg.alpha = 0; + backBg.scrollFactor.set(); + add(backBg); + + bg = new FlxBackdrop(Paths.image('ui/checkeredBG', 'preload'), 1, 1, true, true, 1, 1); + bg.alpha = 0; + bg.antialiasing = true; + bg.scrollFactor.set(); + add(bg); + + + FlxTween.tween(backBg, {alpha: 0.6}, 0.4, {ease: FlxEase.quartInOut}); + FlxTween.tween(bg, {alpha: 0.6}, 0.4, {ease: FlxEase.quartInOut}); + + grpMenuShit = new FlxTypedGroup(); + add(grpMenuShit); + + for (i in 0...menuItems.length) + { + var songText:Alphabet = new Alphabet(0, (70 * i) + 30, LanguageManager.getTextString('${menuItems[i].optionName}'), true, false); + songText.isMenuItem = true; + songText.targetY = i; + grpMenuShit.add(songText); + } + + changeSelection(); + + cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]]; + } + + override function update(elapsed:Float) + { + var scrollSpeed:Float = 50; + bg.x -= scrollSpeed * elapsed; + bg.y -= scrollSpeed * elapsed; + + timeElapsed += elapsed; + + super.update(elapsed); + + var upP = controls.UP_P; + var downP = controls.DOWN_P; + var accepted = controls.ACCEPT; + + if (upP) + { + changeSelection(-1); + } + if (downP) + { + changeSelection(1); + } + + + if (accepted) + { + selectOption(); + } + } + function selectOption() + { + var daSelected:String = menuItems[curSelected].optionName; + + switch (daSelected) + { + case "Exit": + close(); + inMods = false; + + default: + FlxG.save.data.Mod = daSelected; + trace(FlxG.save.data.Mod); + close(); + inMods = false; + if(FlxG.sound.music != null) + FlxG.sound.music.stop(); + TitleState.initialized = false; + FlxG.switchState(new StartStateSelector()); + } + } + override function close() + { + funnyTexts.clear(); + + super.close(); + } + + override function destroy() + { + super.destroy(); + } + + function changeSelection(change:Int = 0):Void + { + curSelected += change; + + if (curSelected < 0) + curSelected = menuItems.length - 1; + if (curSelected >= menuItems.length) + curSelected = 0; + + var bullShit:Int = 0; + + for (item in grpMenuShit.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)); + } + } + } +} +class ModOption +{ + public var optionName:String; + + public function new(optionName:String) + { + this.optionName = optionName; + } + + public static function getOption(list:Array, optionName:String):ModOption + { + for (option in list) + { + if (option.optionName == optionName) + { + return option; + } + } + return null; + } +} \ No newline at end of file diff --git a/source/TitleState.hx b/source/TitleState.hx index 51095ef..423167d 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -1,5 +1,6 @@ package; +import flixel.FlxSubState; import sys.FileSystem; import haxe.Http; import flixel.FlxG; @@ -35,7 +36,7 @@ using StringTools; class TitleState extends MusicBeatState { - static var initialized:Bool = false; + public static var initialized:Bool = false; var blackScreen:FlxSprite; var credGroup:FlxGroup; @@ -51,8 +52,8 @@ class TitleState extends MusicBeatState var eye:FlxSprite; var loopEyeTween:FlxTween; public static var mods:Array = []; - public static var currentMod:String = "test"; - public static var modFolder:String = 'mods/' + currentMod; + public static var currentMod:String = 'test'; + public static var modFolder:String = ''; override public function create():Void @@ -63,6 +64,12 @@ class TitleState extends MusicBeatState // LoadingState.loadAndSwitchState(new SusState()); //} + + if (FlxG.save.data.Mod == null) + FlxG.save.data.Mod = 'test'; // DON'T REMOVE ALL MOD FOLDERS OR CRASH i think + + currentMod = FlxG.save.data.Mod; + modFolder = 'mods/' + currentMod; PlayerSettings.init(); curWacky = FlxG.random.getObject(getIntroTextShit()); @@ -322,8 +329,13 @@ class TitleState extends MusicBeatState { FlxG.switchState(new CompatWarningState()); } + + if (FlxG.keys.justPressed.M) + { + openSubState(new ModSubState(0, 0)); + } - if (pressedEnter && !transitioning && skippedIntro) + if (pressedEnter && !transitioning && skippedIntro && !ModSubState.inMods) { titleText.animation.play('press'); @@ -438,6 +450,11 @@ class TitleState extends MusicBeatState credGroup.add(coolText); textGroup.add(coolText); } + + override function openSubState(SubState:FlxSubState) + { + super.openSubState(SubState); + } function deleteCoolText() {