Implement a debug menu to select difficulty/variation

This commit is contained in:
EliteMasterEric
2025-09-25 06:01:30 -05:00
committed by Abnormal
parent 0c4f22173e
commit d03199ccda
3 changed files with 114 additions and 14 deletions
+5 -10
View File
@@ -37,6 +37,7 @@ import funkin.util.macro.MacroUtil;
import funkin.util.TrackerUtil;
import funkin.util.WindowUtil;
import openfl.display.BitmapData;
import funkin.ui.debug.ChartPlaytestState;
#if FEATURE_DISCORD_RPC
import funkin.api.discord.DiscordClient;
#end
@@ -388,7 +389,10 @@ class InitState extends FlxState
}
else if (params.song.shouldLoadSong && params.song.songPath != null)
{
startSongFromFNFC(params.song.songPath);
FlxG.switchState(() -> new ChartPlaytestState(
{
fnfcFilePath: params.song.songPath,
}));
}
else
{
@@ -449,15 +453,6 @@ class InitState extends FlxState
});
}
function startSongFromFNFC(filePath:String):Void
{
// var difficultyId = Constants.DEFAULT_DIFFICULTY;
// var variationId = Constants.DEFAULT_VARIATION;
var difficultyId = "nightmare";
var variationId = "erect";
funkin.util.file.FNFCUtil.playSongFromFNFCPath(filePath, difficultyId, variationId);
}
/**
* Start the game by directly loading into a specific story mode level.
* @param levelId
@@ -0,0 +1,107 @@
package funkin.ui.debug;
import flixel.text.FlxText;
import flixel.tweens.FlxTween;
import flixel.util.FlxTimer;
import funkin.data.freeplay.player.PlayerRegistry;
import funkin.play.ResultState.ResultsStateParams;
import funkin.ui.MenuList.MenuTypedItem;
import funkin.ui.MenuList.MenuTypedList;
import funkin.ui.options.items.CheckboxPreferenceItem;
import funkin.util.file.FNFCUtil;
/**
* When playtesting from an FNFC file, we display a debug UI to choose a difficulty first.
*/
class ChartPlaytestState extends MusicBeatState
{
var fnfcFilePath:String;
var currentDifficulty:String;
var currentVariation:String;
var items:MenuTypedList<MenuTypedItem<FlxText>>;
public function new(params:ChartPlaytestStateParams)
{
super();
fnfcFilePath = params.fnfcFilePath;
persistentUpdate = false;
persistentDraw = false;
items = new MenuTypedList<MenuTypedItem<FlxText>>();
add(items);
createItems();
}
function createItems():Void
{
createTextItem("Playtest Song", function() {
FNFCUtil.playSongFromFNFCPath(fnfcFilePath, currentDifficulty, currentVariation);
});
createToggleListItem("Variation", Constants.DEFAULT_VARIATION_LIST, function(value:String) {
currentVariation = value;
});
createToggleListItem("Difficulty", Constants.DEFAULT_DIFFICULTY_LIST_FULL, function(value:String) {
currentDifficulty = value;
});
}
function createTextItem(name:String, ?onChange:Void->Void):MenuTypedItem<FlxText>
{
var txt:FlxText = new FlxText(0, 0, name);
txt.antialiasing = false;
txt.setFormat(Paths.font('vcr.ttf'), 32);
var menuItem:MenuTypedItem<FlxText> = new MenuTypedItem<FlxText>(10, 36 * items.length, txt, name, onChange);
menuItem.setEmptyBackground();
menuItem.fireInstantly = true;
return items.addItem(name, menuItem);
}
function createCheckboxItem(name:String, ?onChange:Bool->Void):Void
{
var toggle:Bool = false;
var menuItem:MenuTypedItem<FlxText> = createTextItem(name);
menuItem.callback = function() {
menuItem.label.text = name + ": " + (toggle ? "on" : "off");
toggle = !toggle;
onChange(toggle);
};
}
/**
* Toggles between different options in a list
* @param name
* @param toggleList
* @param onChange
* @return MenuTypedItem<FlxText>
*/
function createToggleListItem(name:String, toggleList:Array<String>, ?onChange:String->Void):MenuTypedItem<FlxText>
{
var toggleCounter:Int = 0;
var menuItem:MenuTypedItem<FlxText> = createTextItem(name);
// We create and call the labelCallback here to initalize it
var labelCallback:Void->Void = function() {
menuItem.label.text = name + ":" + toggleList[toggleCounter];
onChange(toggleList[toggleCounter]);
};
labelCallback();
menuItem.callback = function() {
toggleCounter = (toggleCounter + 1) % toggleList.length;
labelCallback();
};
return menuItem;
}
}
typedef ChartPlaytestStateParams =
{
fnfcFilePath:Null<String>
};
+2 -4
View File
@@ -151,10 +151,8 @@ class CLIUtil
},
song:
{
// shouldLoadSong: false,
// songPath: null
shouldLoadSong: true,
songPath: "E:/Programming/Funkin'/SECRET/Chart v0.8/milf.fnfc"
shouldLoadSong: false,
songPath: null
}
};
}