1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-09-01 03:15:53 +00:00
Funkin/source/funkin/ui/debug/DebugMenuSubState.hx

151 lines
3.9 KiB
Haxe
Raw Permalink Normal View History

package funkin.ui.debug;
import flixel.math.FlxPoint;
import flixel.FlxObject;
import flixel.FlxSprite;
import funkin.ui.MusicBeatSubState;
import funkin.ui.FullScreenScaleMode;
2024-03-23 21:50:48 +00:00
import funkin.audio.FunkinSound;
import funkin.ui.TextMenuList;
import funkin.ui.debug.charting.ChartEditorState;
2023-11-21 06:37:49 +00:00
import funkin.util.logging.CrashHandler;
2023-11-21 21:09:13 +00:00
import flixel.addons.transition.FlxTransitionableState;
import funkin.util.FileUtil;
2023-06-09 19:44:29 +00:00
class DebugMenuSubState extends MusicBeatSubState
{
var items:TextMenuList;
/**
* Camera focus point
*/
var camFocusPoint:FlxObject;
2023-04-06 05:39:27 +00:00
override function create():Void
{
2023-12-11 22:38:16 +00:00
FlxTransitionableState.skipNextTransIn = true;
super.create();
2023-12-11 22:38:16 +00:00
2023-04-06 05:39:27 +00:00
bgColor = 0x00000000;
// Create an object for the camera to track.
camFocusPoint = new FlxObject(0, 0);
add(camFocusPoint);
// Follow the camera focus as we scroll.
FlxG.camera.follow(camFocusPoint, null, 0.06);
// Create the green background.
var menuBG = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
menuBG.color = 0xFF4CAF50;
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1 * FullScreenScaleMode.wideScale.x));
menuBG.updateHitbox();
menuBG.screenCenter();
menuBG.scrollFactor.set(0, 0);
add(menuBG);
// Create the list for menu items.
items = new TextMenuList();
// Move the camera when the menu is scrolled.
items.onChange.add(onMenuChange);
add(items);
2024-01-09 18:16:00 +00:00
FlxTransitionableState.skipNextTransIn = true;
// Create each menu item.
// Call onMenuChange when the first item is created to move the camera .
#if FEATURE_CHART_EDITOR
createItem("CHART EDITOR", openChartEditor);
#end
#if FEATURE_ANIMATION_EDITOR
createItem("ANIMATION EDITOR", openAnimationEditor);
#end
#if FEATURE_STAGE_EDITOR
2024-09-29 17:07:09 +00:00
createItem("STAGE EDITOR", openStageEditor);
#end
2025-03-31 23:51:22 +00:00
#if FEATURE_RESULTS_DEBUG
createItem("RESULTS SCREEN DEBUG", openTestResultsScreen);
2025-03-31 23:51:22 +00:00
#end
2023-11-21 06:37:49 +00:00
#if sys
createItem("OPEN CRASH LOG FOLDER", openLogFolder);
#end
onMenuChange(items.members[0]);
FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y + 500));
2025-06-19 07:52:51 +00:00
// Remove the "user" stylesheet to prevent components using incorrect style data when entering an editor.
haxe.ui.Toolkit.styleSheet.clear("user");
}
function onMenuChange(selected:TextMenuItem)
{
camFocusPoint.setPosition(selected.x + selected.width / 2, selected.y + selected.height / 2);
}
override function update(elapsed:Float):Void
{
super.update(elapsed);
if (controls.BACK)
{
2024-03-23 21:50:48 +00:00
FunkinSound.playOnce(Paths.sound('cancelMenu'));
exitDebugMenu();
}
}
function createItem(name:String, callback:Void->Void, fireInstantly = false):TextMenuItem
{
var item = items.createItem(0, 100 + items.length * 100, name, BOLD, callback);
item.fireInstantly = fireInstantly;
item.screenCenter(X);
return item;
}
2025-05-28 23:19:08 +00:00
function openChartEditor():Void
{
2023-11-21 21:09:13 +00:00
FlxTransitionableState.skipNextTransIn = true;
FlxG.switchState(() -> new ChartEditorState());
}
2025-05-28 23:19:08 +00:00
function openCharSelect():Void
2024-06-15 04:59:58 +00:00
{
2025-05-28 23:19:08 +00:00
FlxG.switchState(() -> new funkin.ui.charSelect.CharSelectSubState());
2024-06-15 04:59:58 +00:00
}
2025-05-28 23:19:08 +00:00
function openAnimationEditor():Void
{
FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState());
trace('Animation Editor');
}
2025-05-28 23:19:08 +00:00
function testStickers():Void
2023-04-05 04:56:02 +00:00
{
openSubState(new funkin.ui.transition.stickers.StickerSubState({}));
2023-04-05 04:56:02 +00:00
trace('opened stickers');
}
2025-05-28 23:19:08 +00:00
function openStageEditor():Void
{
trace('Stage Editor');
FlxG.switchState(() -> new funkin.ui.debug.stageeditor.StageEditorState());
}
function openTestResultsScreen():Void
{
FlxG.switchState(() -> new funkin.ui.debug.results.ResultsDebugSubState());
}
2023-11-21 06:37:49 +00:00
#if sys
function openLogFolder()
{
FileUtil.openFolder(CrashHandler.LOG_FOLDER);
2023-11-21 06:37:49 +00:00
}
#end
function exitDebugMenu()
{
// TODO: Add a transition?
this.close();
}
}