Skip to content

Commit

Permalink
YES YOU CAN PICK MODS NOW
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLikesKirby committed May 18, 2024
1 parent 9d557fe commit 28d4fe6
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
194 changes: 194 additions & 0 deletions source/ModSubState.hx
Original file line number Diff line number Diff line change
@@ -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<Alphabet>;
var bg:FlxBackdrop;

// First, create an empty array
var menuItems:Array<ModOption> = [];

var curSelected:Int = 0;

var expungedSelectWaitTime:Float = 0;
var timeElapsed:Float = 0;
var patienceTime:Float = 0;

var funnyTexts:FlxTypedGroup<FlxText> = new FlxTypedGroup<FlxText>();
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<FlxText>();
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<Alphabet>();
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<ModOption>, optionName:String):ModOption
{
for (option in list)
{
if (option.optionName == optionName)
{
return option;
}
}
return null;
}
}
25 changes: 21 additions & 4 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package;

import flixel.FlxSubState;
import sys.FileSystem;
import haxe.Http;
import flixel.FlxG;
Expand Down Expand Up @@ -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;
Expand All @@ -51,8 +52,8 @@ class TitleState extends MusicBeatState
var eye:FlxSprite;
var loopEyeTween:FlxTween;
public static var mods:Array<String> = [];
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
Expand All @@ -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());
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -438,6 +450,11 @@ class TitleState extends MusicBeatState
credGroup.add(coolText);
textGroup.add(coolText);
}

override function openSubState(SubState:FlxSubState)
{
super.openSubState(SubState);
}

function deleteCoolText()
{
Expand Down

0 comments on commit 28d4fe6

Please sign in to comment.