-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathModSwitchMenu.hx
More file actions
84 lines (65 loc) · 1.98 KB
/
ModSwitchMenu.hx
File metadata and controls
84 lines (65 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package funkin.menus;
#if MOD_SUPPORT
import flixel.tweens.FlxTween;
import flixel.util.FlxColor;
import funkin.backend.assets.ModsFolder;
import haxe.io.Path;
import sys.FileSystem;
class ModSwitchMenu extends MusicBeatSubstate {
var mods:Array<String> = [];
var alphabets:FlxTypedGroup<Alphabet>;
var curSelected:Int = 0;
var subCam:FlxCamera;
public override function create() {
super.create();
camera = subCam = new FlxCamera();
subCam.bgColor = 0;
FlxG.cameras.add(subCam, false);
var bg = new FlxSprite(0, 0).makeSolid(FlxG.width, FlxG.height, 0xFF000000);
bg.updateHitbox();
bg.scrollFactor.set();
add(bg);
bg.alpha = 0;
FlxTween.tween(bg, {alpha: 0.5}, 0.25, {ease: FlxEase.cubeOut});
mods = ModsFolder.getModsList();
CoolUtil.sortAlphabetically(ModsFolder.getModsList(),true);
mods.push(null);
alphabets = new FlxTypedGroup<Alphabet>();
for(mod in mods) {
var a = new Alphabet(0, 0, mod == null ? TU.translate("mods.disableMods") : Path.withoutExtension(mod), "bold");
if(mod == ModsFolder.currentModFolder)
a.color = FlxColor.LIME;
a.isMenuItem = true;
a.scrollFactor.set();
alphabets.add(a);
}
add(alphabets);
changeSelection(0, true);
}
public override function update(elapsed:Float) {
super.update(elapsed);
changeSelection((controls.DOWN_P ? 1 : 0) + (controls.UP_P ? -1 : 0) - FlxG.mouse.wheel);
if (controls.ACCEPT) {
ModsFolder.switchMod(mods[curSelected]);
close();
}
if (controls.BACK)
close();
}
public function changeSelection(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
curSelected = FlxMath.wrap(curSelected + change, 0, alphabets.length-1);
CoolUtil.playMenuSFX(SCROLL, 0.7);
for(k=>alphabet in alphabets.members) {
alphabet.alpha = 0.6;
alphabet.targetY = k - curSelected;
}
alphabets.members[curSelected].alpha = 1;
}
override function destroy() {
super.destroy();
if (FlxG.cameras.list.contains(subCam))
FlxG.cameras.remove(subCam);
}
}
#end