Skip to content

Commit 6f7c3a4

Browse files
bctixNexIsDumb
andauthored
Options/Credits from multiple asset libraries + Fix options transition when exiting Controls (#367)
* load all options from all asset libraries * add override for options * removing overridedMods * fixing the options transin not appearing when exiting keybinds substate * making it for credits too --------- Co-authored-by: ⍚~Nex <[email protected]>
1 parent 1995c7f commit 6f7c3a4

File tree

3 files changed

+29
-46
lines changed

3 files changed

+29
-46
lines changed

source/funkin/menus/credits/CreditsMain.hx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package funkin.menus.credits;
22

3+
import flixel.util.FlxColor;
4+
import funkin.backend.assets.AssetsLibraryList.AssetSource;
35
import funkin.options.OptionsScreen;
4-
import funkin.options.type.*;
56
import funkin.options.TreeMenu;
7+
import funkin.options.type.*;
68
import haxe.xml.Access;
7-
import flixel.util.FlxColor;
89

910
class CreditsMain extends TreeMenu {
1011
var bg:FlxSprite;
@@ -20,21 +21,17 @@ class CreditsMain extends TreeMenu {
2021
bg.antialiasing = true;
2122
add(bg);
2223

23-
var xmlPath = Paths.xml('config/credits');
24-
for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) {
25-
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) {
26-
var access:Access = null;
27-
try {
28-
access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT", source)));
29-
} catch(e) {
30-
Logs.trace('Error while parsing credits.xml: ${Std.string(e)}', ERROR);
31-
}
24+
for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) {
25+
var xmlPath = Paths.xml('config/credits/LIB_$i');
3226

33-
if (access != null)
34-
for(c in parseCreditsFromXML(access, source))
35-
items.push(c);
27+
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT")) {
28+
var access:Access = null;
29+
try access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT")))
30+
catch(e) Logs.trace('Error while parsing credits.xml: ${Std.string(e)}', ERROR);
31+
if (access != null) for (c in parseCreditsFromXML(access)) items.push(c);
3632
}
3733
}
34+
3835
items.push(new TextOption("Codename Engine >", "Select this to see all the contributors of the engine!", function() {
3936
optionsTree.add(Type.createInstance(CreditsCodename, []));
4037
}));
@@ -51,7 +48,7 @@ class CreditsMain extends TreeMenu {
5148
/**
5249
* XML STUFF
5350
*/
54-
public function parseCreditsFromXML(xml:Access, source:Bool):Array<OptionType> {
51+
public function parseCreditsFromXML(xml:Access, source:AssetSource = BOTH):Array<OptionType> {
5552
var credsMenus:Array<OptionType> = [];
5653

5754
for(node in xml.elements) {

source/funkin/options/OptionsMenu.hx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,24 @@ class OptionsMenu extends TreeMenu {
5353
if (o.substate != null) {
5454
persistentUpdate = false;
5555
persistentDraw = true;
56-
if (o.substate is MusicBeatSubstate) {
57-
openSubState(o.substate);
58-
} else {
59-
openSubState(Type.createInstance(o.substate, []));
60-
}
56+
if (o.substate is MusicBeatSubstate) openSubState(o.substate);
57+
else openSubState(Type.createInstance(o.substate, []));
6158
} else {
62-
if (o.state is OptionsScreen) {
63-
optionsTree.add(o.state);
64-
} else {
65-
optionsTree.add(Type.createInstance(o.state, []));
66-
}
59+
if (o.state is OptionsScreen) optionsTree.add(o.state);
60+
else optionsTree.add(Type.createInstance(o.state, []));
6761
}
6862
})]);
6963

70-
var xmlPath = Paths.xml("config/options");
71-
for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) {
72-
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) {
64+
for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) {
65+
var xmlPath = Paths.xml('config/options/LIB_$i');
66+
67+
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT")) {
7368
var access:Access = null;
74-
try {
75-
access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT", source)));
76-
} catch(e) {
77-
Logs.trace('Error while parsing options.xml: ${Std.string(e)}', ERROR);
78-
}
79-
80-
if (access != null)
81-
for(o in parseOptionsFromXML(access))
82-
main.add(o);
69+
try access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT")))
70+
catch(e) Logs.trace('Error while parsing options.xml: ${Std.string(e)}', ERROR);
71+
if (access != null) for (o in parseOptionsFromXML(access)) main.add(o);
8372
}
8473
}
85-
8674
}
8775

8876
public override function exit() {

source/funkin/options/keybinds/KeybindsOptions.hx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,8 @@ class KeybindsOptions extends MusicBeatSubstate {
205205
public override function update(elapsed:Float) {
206206
super.update(elapsed);
207207

208-
209-
if (isSubState) {
210-
bg.alpha = lerp(bg.alpha, 0.1, 0.125);
211-
} else {
208+
if (isSubState) bg.alpha = lerp(bg.alpha, 0.1, 0.125);
209+
else {
212210
if (curSelected < 4) {
213211
if (coloredBG.alpha == 0)
214212
coloredBG.color = noteColors[curSelected];
@@ -224,11 +222,11 @@ class KeybindsOptions extends MusicBeatSubstate {
224222
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
225223

226224
if (controls.BACK) {
227-
MusicBeatState.skipTransIn = true;
228-
if (isSubState)
229-
close();
230-
else
225+
if (isSubState) close();
226+
else {
227+
MusicBeatState.skipTransIn = true;
231228
FlxG.switchState(new OptionsMenu());
229+
}
232230
Options.applyKeybinds();
233231
Options.save();
234232
return;

0 commit comments

Comments
 (0)