2021-03-10 00:41:03 +00:00
|
|
|
package;
|
|
|
|
|
2021-03-10 05:27:57 +00:00
|
|
|
import Controls.Control;
|
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
2021-03-10 00:41:03 +00:00
|
|
|
import flixel.text.FlxText;
|
2021-03-10 05:27:57 +00:00
|
|
|
import flixel.util.FlxColor;
|
|
|
|
import polymod.Polymod;
|
2021-03-10 22:01:57 +00:00
|
|
|
#if desktop
|
2021-03-10 00:41:03 +00:00
|
|
|
import sys.FileSystem;
|
2021-03-10 22:01:57 +00:00
|
|
|
#end
|
2021-03-10 00:41:03 +00:00
|
|
|
|
|
|
|
class ModdingSubstate extends MusicBeatSubstate
|
|
|
|
{
|
2021-03-10 05:27:57 +00:00
|
|
|
var grpMods:FlxTypedGroup<ModMenuItem>;
|
|
|
|
var enabledMods:Array<String> = [];
|
|
|
|
var modFolders:Array<String> = [];
|
|
|
|
|
|
|
|
var curSelected:Int = 0;
|
|
|
|
|
2021-03-10 00:41:03 +00:00
|
|
|
public function new():Void
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2021-03-10 05:27:57 +00:00
|
|
|
grpMods = new FlxTypedGroup<ModMenuItem>();
|
|
|
|
add(grpMods);
|
|
|
|
|
|
|
|
refreshModList();
|
|
|
|
}
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.justPressed.R)
|
|
|
|
refreshModList();
|
|
|
|
|
|
|
|
selections();
|
|
|
|
|
2021-03-24 20:44:58 +00:00
|
|
|
if (controls.UI_UP_P)
|
2021-03-10 05:27:57 +00:00
|
|
|
selections(-1);
|
2021-03-24 20:44:58 +00:00
|
|
|
if (controls.UI_DOWN_P)
|
2021-03-10 05:27:57 +00:00
|
|
|
selections(1);
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.SPACE)
|
|
|
|
grpMods.members[curSelected].modEnabled = !grpMods.members[curSelected].modEnabled;
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.I && curSelected != 0)
|
|
|
|
{
|
|
|
|
var oldOne = grpMods.members[curSelected - 1];
|
|
|
|
grpMods.members[curSelected - 1] = grpMods.members[curSelected];
|
|
|
|
grpMods.members[curSelected] = oldOne;
|
|
|
|
selections(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.K && curSelected < grpMods.members.length - 1)
|
|
|
|
{
|
|
|
|
var oldOne = grpMods.members[curSelected + 1];
|
|
|
|
grpMods.members[curSelected + 1] = grpMods.members[curSelected];
|
|
|
|
grpMods.members[curSelected] = oldOne;
|
|
|
|
selections(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function selections(change:Int = 0):Void
|
|
|
|
{
|
|
|
|
curSelected += change;
|
|
|
|
|
|
|
|
if (curSelected >= modFolders.length)
|
|
|
|
curSelected = 0;
|
|
|
|
if (curSelected < 0)
|
|
|
|
curSelected = modFolders.length - 1;
|
|
|
|
|
|
|
|
for (txt in 0...grpMods.length)
|
|
|
|
{
|
|
|
|
if (txt == curSelected)
|
|
|
|
{
|
|
|
|
grpMods.members[txt].color = FlxColor.YELLOW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
grpMods.members[txt].color = FlxColor.WHITE;
|
|
|
|
}
|
|
|
|
|
|
|
|
organizeByY();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function refreshModList():Void
|
|
|
|
{
|
|
|
|
while (grpMods.members.length > 0)
|
|
|
|
{
|
|
|
|
grpMods.remove(grpMods.members[0], true);
|
|
|
|
}
|
2021-03-10 00:41:03 +00:00
|
|
|
|
2021-03-10 22:01:57 +00:00
|
|
|
#if desktop
|
2021-03-10 00:41:03 +00:00
|
|
|
var modList = [];
|
2021-03-10 05:27:57 +00:00
|
|
|
modFolders = [];
|
2021-03-10 00:41:03 +00:00
|
|
|
|
|
|
|
for (file in FileSystem.readDirectory('./mods'))
|
|
|
|
{
|
2021-03-10 05:27:57 +00:00
|
|
|
if (FileSystem.isDirectory('./mods/' + file))
|
|
|
|
modFolders.push(file);
|
2021-03-10 00:41:03 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 05:27:57 +00:00
|
|
|
enabledMods = [];
|
|
|
|
|
|
|
|
modList = Polymod.scan('./mods');
|
|
|
|
|
2021-03-10 00:41:03 +00:00
|
|
|
trace(modList);
|
|
|
|
|
|
|
|
var loopNum:Int = 0;
|
2021-03-10 05:27:57 +00:00
|
|
|
for (i in modFolders)
|
2021-03-10 00:41:03 +00:00
|
|
|
{
|
2021-03-10 05:27:57 +00:00
|
|
|
var txt:ModMenuItem = new ModMenuItem(0, 10 + (40 * loopNum), 0, i, 32);
|
|
|
|
txt.text = i;
|
|
|
|
grpMods.add(txt);
|
2021-03-10 00:41:03 +00:00
|
|
|
|
|
|
|
loopNum++;
|
|
|
|
}
|
2021-03-10 22:01:57 +00:00
|
|
|
#end
|
2021-03-18 20:26:39 +00:00
|
|
|
}
|
2021-03-10 05:27:57 +00:00
|
|
|
|
2021-03-18 20:26:39 +00:00
|
|
|
private function organizeByY():Void
|
|
|
|
{
|
|
|
|
for (i in 0...grpMods.length)
|
2021-03-10 05:27:57 +00:00
|
|
|
{
|
2021-03-18 20:26:39 +00:00
|
|
|
grpMods.members[i].y = 10 + (40 * i);
|
2021-03-10 05:27:57 +00:00
|
|
|
}
|
2021-03-18 20:26:39 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-10 05:27:57 +00:00
|
|
|
|
2021-03-18 20:26:39 +00:00
|
|
|
class ModMenuItem extends FlxText
|
|
|
|
{
|
|
|
|
public var modEnabled:Bool = false;
|
|
|
|
public var daMod:String;
|
2021-03-10 05:27:57 +00:00
|
|
|
|
2021-03-18 20:26:39 +00:00
|
|
|
public function new(x:Float, y:Float, w:Float, str:String, size:Int)
|
|
|
|
{
|
|
|
|
super(x, y, w, str, size);
|
|
|
|
}
|
2021-03-10 05:27:57 +00:00
|
|
|
|
2021-03-18 20:26:39 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
if (modEnabled)
|
|
|
|
alpha = 1;
|
|
|
|
else
|
|
|
|
alpha = 0.5;
|
2021-03-10 05:27:57 +00:00
|
|
|
|
2021-03-18 20:26:39 +00:00
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
}
|