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 <87421482+NexIsDumb@users.noreply.github.com>
This commit is contained in:
bctix
2025-07-06 00:14:34 +02:00
committed by GitHub
co-authored by ⍚~Nex
parent 1995c7ff93
commit 6f7c3a4278
3 changed files with 31 additions and 48 deletions
+14 -17
View File
@@ -1,10 +1,11 @@
package funkin.menus.credits;
import funkin.options.OptionsScreen;
import funkin.options.type.*;
import funkin.options.TreeMenu;
import haxe.xml.Access;
import flixel.util.FlxColor;
import funkin.backend.assets.AssetsLibraryList.AssetSource;
import funkin.options.OptionsScreen;
import funkin.options.TreeMenu;
import funkin.options.type.*;
import haxe.xml.Access;
class CreditsMain extends TreeMenu {
var bg:FlxSprite;
@@ -20,21 +21,17 @@ class CreditsMain extends TreeMenu {
bg.antialiasing = true;
add(bg);
var xmlPath = Paths.xml('config/credits');
for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) {
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) {
var access:Access = null;
try {
access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT", source)));
} catch(e) {
Logs.trace('Error while parsing credits.xml: ${Std.string(e)}', ERROR);
}
for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) {
var xmlPath = Paths.xml('config/credits/LIB_$i');
if (access != null)
for(c in parseCreditsFromXML(access, source))
items.push(c);
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT")) {
var access:Access = null;
try access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT")))
catch(e) Logs.trace('Error while parsing credits.xml: ${Std.string(e)}', ERROR);
if (access != null) for (c in parseCreditsFromXML(access)) items.push(c);
}
}
items.push(new TextOption("Codename Engine >", "Select this to see all the contributors of the engine!", function() {
optionsTree.add(Type.createInstance(CreditsCodename, []));
}));
@@ -51,7 +48,7 @@ class CreditsMain extends TreeMenu {
/**
* XML STUFF
*/
public function parseCreditsFromXML(xml:Access, source:Bool):Array<OptionType> {
public function parseCreditsFromXML(xml:Access, source:AssetSource = BOTH):Array<OptionType> {
var credsMenus:Array<OptionType> = [];
for(node in xml.elements) {
+11 -23
View File
@@ -53,36 +53,24 @@ class OptionsMenu extends TreeMenu {
if (o.substate != null) {
persistentUpdate = false;
persistentDraw = true;
if (o.substate is MusicBeatSubstate) {
openSubState(o.substate);
} else {
openSubState(Type.createInstance(o.substate, []));
}
if (o.substate is MusicBeatSubstate) openSubState(o.substate);
else openSubState(Type.createInstance(o.substate, []));
} else {
if (o.state is OptionsScreen) {
optionsTree.add(o.state);
} else {
optionsTree.add(Type.createInstance(o.state, []));
}
if (o.state is OptionsScreen) optionsTree.add(o.state);
else optionsTree.add(Type.createInstance(o.state, []));
}
})]);
var xmlPath = Paths.xml("config/options");
for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) {
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) {
var access:Access = null;
try {
access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT", source)));
} catch(e) {
Logs.trace('Error while parsing options.xml: ${Std.string(e)}', ERROR);
}
for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) {
var xmlPath = Paths.xml('config/options/LIB_$i');
if (access != null)
for(o in parseOptionsFromXML(access))
main.add(o);
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT")) {
var access:Access = null;
try access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT")))
catch(e) Logs.trace('Error while parsing options.xml: ${Std.string(e)}', ERROR);
if (access != null) for (o in parseOptionsFromXML(access)) main.add(o);
}
}
}
public override function exit() {
@@ -205,10 +205,8 @@ class KeybindsOptions extends MusicBeatSubstate {
public override function update(elapsed:Float) {
super.update(elapsed);
if (isSubState) {
bg.alpha = lerp(bg.alpha, 0.1, 0.125);
} else {
if (isSubState) bg.alpha = lerp(bg.alpha, 0.1, 0.125);
else {
if (curSelected < 4) {
if (coloredBG.alpha == 0)
coloredBG.color = noteColors[curSelected];
@@ -224,11 +222,11 @@ class KeybindsOptions extends MusicBeatSubstate {
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
if (controls.BACK) {
MusicBeatState.skipTransIn = true;
if (isSubState)
close();
else
if (isSubState) close();
else {
MusicBeatState.skipTransIn = true;
FlxG.switchState(new OptionsMenu());
}
Options.applyKeybinds();
Options.save();
return;