Funkin/source/funkin/ui/debug/DebugMenuSubState.hx

141 lines
3.5 KiB
Haxe
Raw Normal View History

package funkin.ui.debug;
import flixel.math.FlxPoint;
import flixel.FlxObject;
import flixel.FlxSprite;
import funkin.ui.MusicBeatSubState;
2024-03-23 17:50:48 -04:00
import funkin.audio.FunkinSound;
import funkin.ui.TextMenuList;
import funkin.ui.debug.charting.ChartEditorState;
import funkin.ui.MusicBeatSubState;
2023-11-21 01:37:49 -05:00
import funkin.util.logging.CrashHandler;
2023-11-21 16:09:13 -05:00
import flixel.addons.transition.FlxTransitionableState;
import funkin.util.FileUtil;
2023-06-09 15:44:29 -04:00
class DebugMenuSubState extends MusicBeatSubState
{
var items:TextMenuList;
/**
* Camera focus point
*/
var camFocusPoint:FlxObject;
2023-04-06 01:39:27 -04:00
override function create():Void
{
2023-12-11 17:38:16 -05:00
FlxTransitionableState.skipNextTransIn = true;
super.create();
2023-12-11 17:38:16 -05:00
2023-04-06 01:39:27 -04: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));
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 13:16:00 -05:00
FlxTransitionableState.skipNextTransIn = true;
// Create each menu item.
// Call onMenuChange when the first item is created to move the camera .
onMenuChange(createItem("CHART EDITOR", openChartEditor));
2024-05-02 20:06:08 -04:00
// createItem("Input Offset Testing", openInputOffsetTesting);
2024-06-15 00:59:58 -04:00
createItem("CHARACTER SELECT", openCharSelect, true);
createItem("ANIMATION EDITOR", openAnimationEditor);
2024-05-02 20:06:08 -04:00
// createItem("STAGE EDITOR", openStageEditor);
// createItem("TEST STICKERS", testStickers);
2023-11-21 01:37:49 -05:00
#if sys
createItem("OPEN CRASH LOG FOLDER", openLogFolder);
#end
FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y + 500));
}
function onMenuChange(selected:TextMenuItem)
{
camFocusPoint.setPosition(selected.x + selected.width / 2, selected.y + selected.height / 2);
}
override function update(elapsed:Float)
{
super.update(elapsed);
if (controls.BACK)
{
2024-03-23 17:50:48 -04:00
FunkinSound.playOnce(Paths.sound('cancelMenu'));
exitDebugMenu();
}
}
function createItem(name:String, callback:Void->Void, fireInstantly = false)
{
var item = items.createItem(0, 100 + items.length * 100, name, BOLD, callback);
item.fireInstantly = fireInstantly;
item.screenCenter(X);
return item;
}
function openChartEditor()
{
2023-11-21 16:09:13 -05:00
FlxTransitionableState.skipNextTransIn = true;
FlxG.switchState(() -> new ChartEditorState());
}
2023-12-12 23:28:16 -05:00
function openInputOffsetTesting()
{
2024-02-12 20:06:43 -05:00
openSubState(new funkin.ui.debug.latency.LatencyState());
2023-12-12 23:28:16 -05:00
trace('Input Offset Testing');
}
2024-06-15 00:59:58 -04:00
function openCharSelect()
{
FlxG.switchState(new funkin.ui.charSelect.CharSelectSubState());
}
function openAnimationEditor()
{
FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState());
trace('Animation Editor');
}
2023-04-05 00:56:02 -04:00
function testStickers()
{
openSubState(new funkin.ui.transition.StickerSubState());
2023-04-05 00:56:02 -04:00
trace('opened stickers');
}
function openStageEditor()
{
trace('Stage Editor');
}
2023-11-21 01:37:49 -05:00
#if sys
function openLogFolder()
{
FileUtil.openFolder(CrashHandler.LOG_FOLDER);
2023-11-21 01:37:49 -05:00
}
#end
function exitDebugMenu()
{
// TODO: Add a transition?
this.close();
}
}