2022-09-07 23:07:08 +00:00
|
|
|
package funkin.ui.debug;
|
|
|
|
|
2023-07-26 20:52:58 +00:00
|
|
|
import flixel.math.FlxPoint;
|
2022-09-07 23:07:08 +00:00
|
|
|
import flixel.FlxObject;
|
|
|
|
import flixel.FlxSprite;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.ui.MusicBeatSubState;
|
2024-03-23 21:50:48 +00:00
|
|
|
import funkin.audio.FunkinSound;
|
2022-09-07 23:07:08 +00:00
|
|
|
import funkin.ui.TextMenuList;
|
|
|
|
import funkin.ui.debug.charting.ChartEditorState;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.ui.MusicBeatSubState;
|
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;
|
2024-02-16 10:24:43 +00:00
|
|
|
import funkin.util.FileUtil;
|
2022-09-07 23:07:08 +00:00
|
|
|
|
2023-06-09 19:44:29 +00:00
|
|
|
class DebugMenuSubState extends MusicBeatSubState
|
2022-09-07 23:07:08 +00:00
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
var items:TextMenuList;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Camera focus point
|
|
|
|
*/
|
|
|
|
var camFocusPoint:FlxObject;
|
|
|
|
|
2023-04-06 05:39:27 +00:00
|
|
|
override function create():Void
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-12-11 22:38:16 +00:00
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
2023-01-23 03:25:45 +00:00
|
|
|
super.create();
|
2023-12-11 22:38:16 +00:00
|
|
|
|
2023-04-06 05:39:27 +00:00
|
|
|
bgColor = 0x00000000;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
// 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 18:16:00 +00:00
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
// Create each menu item.
|
|
|
|
// Call onMenuChange when the first item is created to move the camera .
|
|
|
|
onMenuChange(createItem("CHART EDITOR", openChartEditor));
|
2023-12-13 04:28:16 +00:00
|
|
|
createItem("Input Offset Testing", openInputOffsetTesting);
|
2023-01-23 03:25:45 +00:00
|
|
|
createItem("ANIMATION EDITOR", openAnimationEditor);
|
|
|
|
createItem("STAGE EDITOR", openStageEditor);
|
2023-04-05 04:56:02 +00:00
|
|
|
createItem("TEST STICKERS", testStickers);
|
2023-11-21 06:37:49 +00:00
|
|
|
#if sys
|
|
|
|
createItem("OPEN CRASH LOG FOLDER", openLogFolder);
|
|
|
|
#end
|
2023-07-26 20:52:58 +00:00
|
|
|
FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y));
|
|
|
|
FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y + 500));
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 21:50:48 +00:00
|
|
|
FunkinSound.playOnce(Paths.sound('cancelMenu'));
|
2023-01-23 03:25:45 +00:00
|
|
|
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 21:09:13 +00:00
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new ChartEditorState());
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
2023-12-13 04:28:16 +00:00
|
|
|
function openInputOffsetTesting()
|
|
|
|
{
|
2024-02-13 01:06:43 +00:00
|
|
|
openSubState(new funkin.ui.debug.latency.LatencyState());
|
2023-12-13 04:28:16 +00:00
|
|
|
trace('Input Offset Testing');
|
|
|
|
}
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
function openAnimationEditor()
|
|
|
|
{
|
2024-02-06 00:46:11 +00:00
|
|
|
FlxG.switchState(() -> new funkin.ui.debug.anim.DebugBoundingState());
|
2023-01-23 03:25:45 +00:00
|
|
|
trace('Animation Editor');
|
|
|
|
}
|
|
|
|
|
2023-04-05 04:56:02 +00:00
|
|
|
function testStickers()
|
|
|
|
{
|
2023-11-07 09:04:22 +00:00
|
|
|
openSubState(new funkin.ui.transition.StickerSubState());
|
2023-04-05 04:56:02 +00:00
|
|
|
trace('opened stickers');
|
|
|
|
}
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
function openStageEditor()
|
|
|
|
{
|
|
|
|
trace('Stage Editor');
|
|
|
|
}
|
|
|
|
|
2023-11-21 06:37:49 +00:00
|
|
|
#if sys
|
|
|
|
function openLogFolder()
|
|
|
|
{
|
2024-02-16 10:24:43 +00:00
|
|
|
FileUtil.openFolder(CrashHandler.LOG_FOLDER);
|
2023-11-21 06:37:49 +00:00
|
|
|
}
|
|
|
|
#end
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
function exitDebugMenu()
|
|
|
|
{
|
|
|
|
// TODO: Add a transition?
|
|
|
|
this.close();
|
|
|
|
}
|
2022-09-07 23:07:08 +00:00
|
|
|
}
|